Пример #1
0
        /// <summary>
        /// Promotes the size of this rule for a given reference item.
        /// </summary>
        private void PromoteFor(Item refItem)
        {
            MaterialItem item = refItem as MaterialItem;

            if (item != null &&
                item.Material.Material == Material.Material &&
                item.Shape == Shape)
            {
                Size = item.Size;
            }
        }
Пример #2
0
        public override void OnUse(Player player, vec3 _worldPos, vec3 _worldNormal, Entity _hitEntity)
        {
            if (!previewPlacable || player == null)
            {
                return;
            }

            Item droppedItem = new MaterialItem(Material, Shape, Size);

            player.Inventory.RemoveItem(droppedItem);

            ItemEntity itemEntity = new ItemEntity(droppedItem);

            player.ContainingWorld.AddEntity(itemEntity, previewPlaceMatrix);
        }
Пример #3
0
        /// <summary>
        /// Special rule: if only different sizes, it could be dismantled
        /// </summary>
        public override bool CouldBeDismantled(Item _item)
        {
            MaterialItem item = _item as MaterialItem;

            if (item != null &&
                item.Material.Material == Material.Material &&
                item.Shape == Shape)
            {
                return(!item.IsEmpty);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// Special rule: if only different sizes, it could be craftable
        /// </summary>
        public override bool CouldBeCraftable(Item _item)
        {
            MaterialItem item = _item as MaterialItem;

            if (item != null &&
                item.Material.Material == Material.Material &&
                item.Shape == Shape)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        /// <summary>
        /// Starts
        /// </summary>
        public static void Startup(IntPtr _unmanagedModule)
        {
            // Get and save the resource domain of the mod, needed for loading resources.
            UpvoidMiner.Mod       = Module.FromHandle(_unmanagedModule);
            UpvoidMiner.ModDomain = UpvoidMiner.Mod.ResourceDomain;

            // Create the world. Multiple worlds could be created here, but we only want one.
            // Use the UpvoidMinerWorldGenerator, which will create a simple terrain with some vegetation.
            World world = Universe.CreateWorld("UpvoidMinerWorld");

            UpvoidMinerWorldGenerator.init(world);
            world.Start();

            for (int i = 0; i < 3; ++i)
            {
                TerrainResource mat = TerrainResource.FromName("Stone." + (i + 1).ToString("00"));
                Debug.Assert(mat != null, "Invalid material");
                MaterialItem testItem = new MaterialItem(mat, MaterialShape.Cube, new vec3(1), 1);

                world.AddEntity(new ItemEntity(testItem), mat4.Translate(new vec3(5f, i * 2f, ((i % 3) * 2f))));
            }
        }
Пример #6
0
        /// <summary>
        /// This can be merged with material items of the same resource and shape and size.
        /// </summary>
        public override bool TryMerge(Item rhs, bool subtract, bool force, bool dryrun = false)
        {
            MaterialItem item = rhs as MaterialItem;

            if (item == null)
            {
                return(false);
            }
            if (item.Material != Material)
            {
                return(false);
            }
            if (item.Shape != Shape)
            {
                return(false);
            }
            if (item.Size != Size)
            {
                return(false);
            }

            return(Merge(item, subtract, force, dryrun));
        }