{"id":223,"date":"2011-06-16T12:32:39","date_gmt":"2011-06-16T10:32:39","guid":{"rendered":"http:\/\/www.ancor.ch\/schoebey\/?p=223"},"modified":"2011-06-16T12:32:39","modified_gmt":"2011-06-16T10:32:39","slug":"designing-an-inventory-system","status":"publish","type":"post","link":"https:\/\/www.ancor.ch\/schoebey\/?p=223","title":{"rendered":"designing an inventory system"},"content":{"rendered":"<h2>inventory system &#8211; draft<\/h2>\n<p>every single object that has been placed in the world has the potential of being picked up and added to the player&#8217;s inventory.<\/p>\n<p>A new action would have to take care of hiding the object and spawning a new inventory item (perhaps a new subclass of cp407object).<\/p>\n<p>The visual representation of the inventory could at first be a simple list, displaying all the items a player has in his\/her possession.<\/p>\n<p>a next step would be to replace the list by thumbnails (RT previews of each object &#8211; in which case subclassing CP407Object would make sense).<\/p>\n<p>Objects in the inventory can be placed on the floor via drag&amp;drop<\/p>\n<p>&nbsp;<\/p>\n<h2>new object properties \/ dynamics<\/h2>\n<p>weight: a thought &#8211; each object consists of a certain material that has a specific weight. The object weight is calculated by multiplying the specific weight with the volume of its bounding box. That way, objects of the same type but with a larger bounding box get heavier, increasing the chance for players not being able to pick them up. It wouldn&#8217;t make much sense if players could pick up cars or trees.<\/p>\n<p>another thought: aging items: consider a seed item a player has in his\/her inventory. As long as it&#8217;s in there, nothing happens to it. If however, the player puts the seed onto (or into) the ground, it starts growing, building a tree, bush, flower, etc. with time.<\/p>\n<p>This principle could be applied to all kinds of objects, such as food items going bad, items that are seasonal or dependant on a certain environment (ice cubes &#8211; as soon as they are picked up, they start melting, gradually turning into a puddle of water)<\/p>\n<p>In order to achieve that, each object has a birth timestamp. Whenever the age is queried, that timestamp is used to compute the object&#8217;s age.<\/p>\n<p>Certain objects would need an &#8216;update&#8217; callback that updates their age without it being queried.<\/p>\n<p>example:<\/p>\n<pre>class CAgingItem\u00c2\u00a0\r\n{\r\n\u00c2\u00a0 void UpdateAge()\r\n\u00c2\u00a0 {\r\n\u00c2\u00a0 \u00c2\u00a0 \u00c2\u00a0 \u00c2\u00a0 m_iAge = CurrentTime() - m_iBirthTime;\r\n\u00c2\u00a0 }\r\n}<\/pre>\n<p>The &#8216;UpdateAge&#8217;-Function gets called periodically (1\/s?).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>inventory system &#8211; draft every single object that has been placed in the world has the potential of being picked up and added to the player&#8217;s inventory. A new action would have to take care of hiding the object and spawning a new inventory item (perhaps a new subclass of cp407object). The visual representation of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,5,4],"tags":[],"class_list":["post-223","post","type-post","status-publish","format-standard","hentry","category-code","category-design","category-p407"],"_links":{"self":[{"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=\/wp\/v2\/posts\/223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=223"}],"version-history":[{"count":5,"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=\/wp\/v2\/posts\/223\/revisions"}],"predecessor-version":[{"id":229,"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=\/wp\/v2\/posts\/223\/revisions\/229"}],"wp:attachment":[{"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}