Example #1
0
        public EntityProperties CreateProperties()
        {
            BlockDropItemStack[] DropsCopy;
            if (Drops == null)
            {
                DropsCopy = null;
            }
            else
            {
                DropsCopy = new BlockDropItemStack[Drops.Length];
                for (int i = 0; i < DropsCopy.Length; i++)
                {
                    DropsCopy[i] = Drops[i].Clone();
                }
            }

            EntityProperties properties = new EntityProperties()
            {
                Code                = Code,
                Class               = Class,
                Habitat             = Habitat,
                HitBoxSize          = HitBoxSize,
                CanClimb            = CanClimb,
                CanClimbAnywhere    = CanClimbAnywhere,
                FallDamage          = FallDamage,
                ClimbTouchDistance  = ClimbTouchDistance,
                RotateModelOnClimb  = RotateModelOnClimb,
                KnockbackResistance = KnockbackResistance,
                Attributes          = Attributes,
                Sounds              = Sounds == null ? new Dictionary <string, AssetLocation>() : new Dictionary <string, AssetLocation>(Sounds),
                IdleSoundChance     = IdleSoundChance,
                IdleSoundRange      = IdleSoundRange,
                Drops               = DropsCopy
            };

            if (Client != null)
            {
                properties.Client = new EntityClientProperties(Client.Behaviors)
                {
                    RendererName         = Client.Renderer,
                    Textures             = new Dictionary <string, CompositeTexture>(Client.Textures),
                    GlowLevel            = Client.GlowLevel,
                    Shape                = Client.Shape,
                    Size                 = Client.Size,
                    Animations           = Client.Animations,
                    AnimationsByMetaCode = Client.AnimationsByMetaCode,
                };
            }

            if (Server != null)
            {
                properties.Server = new EntityServerProperties(Server.Behaviors)
                {
                    Attributes      = Server.Attributes?.ToAttribute() as TreeAttribute,
                    SpawnConditions = Server.SpawnConditions
                };
            }

            properties.SetEyeHeight(EyeHeight);

            return(properties);
        }