Beispiel #1
0
        /// <summary>
        /// Initializes the client properties.
        /// </summary>
        /// <param name="entityTypeCode"></param>
        /// <param name="world"></param>
        public void Init(AssetLocation entityTypeCode, IWorldAccessor world)
        {
            if (Animations != null)
            {
                for (int i = 0; i < Animations.Length; i++)
                {
                    AnimationMetaData animMeta = Animations[i];
                    animMeta.Init();

                    if (animMeta.Animation != null)
                    {
                        AnimationsByMetaCode[animMeta.Code] = animMeta;
                    }

                    if (animMeta.Animation != null)
                    {
                        AnimationsByCrc32[animMeta.CodeCrc32] = animMeta;
                    }
                }
            }


            var cprop = world.EntityTypes.FirstOrDefault(et => et.Code.Equals(entityTypeCode))?.Client;

            LoadedShape           = cprop?.LoadedShape;
            LoadedAlternateShapes = cprop?.LoadedAlternateShapes;
        }
Beispiel #2
0
        public override bool StartAnimation(AnimationMetaData animdata)
        {
            if (ActiveAnimationsByAnimCode.ContainsKey(Personality + "nod"))
            {
                return(false);
            }

            if (PersonalizedAnimations.Contains(animdata.Animation.ToLowerInvariant()))
            {
                if (animdata.Animation == "laugh" && ActiveAnimationsByAnimCode.ContainsKey(Personality + "welcome"))
                {
                    return(false);
                }

                animdata           = animdata.Clone();
                animdata.Animation = Personality + animdata.Animation;
                animdata.Code      = animdata.Animation;
                animdata.CodeCrc32 = AnimationMetaData.GetCrc32(animdata.Code);

                if (animdata.Animation != Personality + "idle")
                {
                    StopAnimation(Personality + "idle");
                }
            }

            return(base.StartAnimation(animdata));
        }
        public override void LoadConfig(JsonObject taskConfig, JsonObject aiConfig)
        {
            base.LoadConfig(taskConfig, aiConfig);

            if (taskConfig["harvestBlocks"] != null)
            {
                harvestBlocks = taskConfig["harvestBlocks"].AsArray <AssetLocation>(new AssetLocation[] { new AssetLocation("pumpkin-fruit-4") });
            }

            if (taskConfig.IsTrue("lumber"))
            {
                lumber = true;
            }

            if (taskConfig["movespeed"] != null)
            {
                moveSpeed = taskConfig["movespeed"].AsFloat(0.02f);
            }

            if (taskConfig["harvestTime"] != null)
            {
                harvestTime = taskConfig["harvestTime"].AsFloat(1.5f);
            }

            if (taskConfig["harvestAnimation"].Exists)
            {
                harvestAnimMeta = new AnimationMetaData()
                {
                    Code           = taskConfig["harvestAnimation"].AsString()?.ToLowerInvariant(),
                    Animation      = taskConfig["harvestAnimation"].AsString()?.ToLowerInvariant(),
                    AnimationSpeed = taskConfig["harvestAnimationSpeed"].AsFloat(1f)
                }.Init();
            }
        }
Beispiel #4
0
        public override void LoadConfig(JsonObject taskConfig, JsonObject aiConfig)
        {
            base.LoadConfig(taskConfig, aiConfig);

            if (taskConfig["movespeed"] != null)
            {
                moveSpeed = taskConfig["movespeed"].AsFloat(0.02f);
            }

            if (taskConfig["placeTime"] != null)
            {
                placeTime = taskConfig["placeTime"].AsFloat(1.5f);
            }

            if (taskConfig["placeAnimation"].Exists)
            {
                placeAnimMeta = new AnimationMetaData()
                {
                    Code           = taskConfig["placeAnimation"].AsString()?.ToLowerInvariant(),
                    Animation      = taskConfig["placeAnimation"].AsString()?.ToLowerInvariant(),
                    AnimationSpeed = taskConfig["placeAnimationSpeed"].AsFloat(1f)
                }.Init();
            }

            if (taskConfig["excludeBlocks"] != null)
            {
                excludeBlocks = AssetLocation.toLocations(taskConfig["excludeBlocks"].AsArray <string>(new string[] { "game:mushroom-*" }));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Does not clone textures and shapes
        /// </summary>
        /// <returns></returns>
        public override EntitySidedProperties Clone()
        {
            AnimationMetaData[] newAnimations = null;
            if (Animations != null)
            {
                newAnimations = new AnimationMetaData[Animations.Length];
                for (int i = 0; i < newAnimations.Length; i++)
                {
                    newAnimations[i] = Animations[i].Clone();
                }
            }

            Dictionary <string, AnimationMetaData> newAnimationsByMetaData = new Dictionary <string, AnimationMetaData>(StringComparer.OrdinalIgnoreCase);

            Dictionary <uint, AnimationMetaData> animsByCrc32 = new Dictionary <uint, AnimationMetaData>();

            foreach (var animation in AnimationsByMetaCode)
            {
                newAnimationsByMetaData[animation.Key] = animation.Value.Clone();
                animsByCrc32[newAnimationsByMetaData[animation.Key].CodeCrc32] = newAnimationsByMetaData[animation.Key];
            }

            return(new EntityClientProperties(BehaviorsAsJsonObj.Clone() as JsonObject[])
            {
                Textures = Textures,
                RendererName = RendererName,
                GlowLevel = GlowLevel,
                Size = Size,
                Shape = Shape?.Clone(),
                Animations = newAnimations,
                AnimationsByMetaCode = newAnimationsByMetaData,
                AnimationsByCrc32 = animsByCrc32
            });
        }
Beispiel #6
0
        public override void LoadConfig(JsonObject taskConfig, JsonObject aiConfig)
        {
            base.LoadConfig(taskConfig, aiConfig);

            if (taskConfig["movespeed"] != null)
            {
                moveSpeed = taskConfig["movespeed"].AsFloat(0.02f);
            }

            if (taskConfig["sitDays"] != null)
            {
                sitDays = taskConfig["sitDays"].AsFloat(1f);
            }

            if (taskConfig["layTime"] != null)
            {
                layTime = taskConfig["layTime"].AsFloat(1.5f);
            }

            if (taskConfig["incubationDays"] != null)
            {
                incubationDays = taskConfig["incubationDays"].AsDouble(5);
            }

            if (taskConfig["sitAnimation"].Exists)
            {
                sitAnimMeta = new AnimationMetaData()
                {
                    Code           = taskConfig["sitAnimation"].AsString()?.ToLowerInvariant(),
                    Animation      = taskConfig["sitAnimation"].AsString()?.ToLowerInvariant(),
                    AnimationSpeed = taskConfig["sitAnimationSpeed"].AsFloat(1f)
                }.Init();
            }

            if (taskConfig["chickCode"] != null)
            {
                chickCode = taskConfig["chickCode"].AsString(null);
            }
            if (taskConfig["portionsEatenForLay"] != null)
            {
                PortionsEatenForLay = taskConfig["portionsEatenForLay"].AsFloat(3);
            }
            if (taskConfig["requiresNearbyEntityCode"] != null)
            {
                requiresNearbyEntityCode = taskConfig["requiresNearbyEntityCode"].AsString(null);
            }
            if (taskConfig["requiresNearbyEntityRange"] != null)
            {
                requiresNearbyEntityRange = taskConfig["requiresNearbyEntityRange"].AsFloat(5);
            }
            if (taskConfig["failBlockCode"] != null)
            {
                string code = taskConfig["failBlockCode"].AsString(null);
                if (code != null)
                {
                    failBlockCode = new AssetLocation(code);
                }
            }
        }
 public void StartAnimation(AnimationMetaData meta)
 {
     if (!activeAnimationsByAnimCode.ContainsKey(meta.Code))
     {
         activeAnimationsByAnimCode[meta.Code] = meta;
         api.World.BlockAccessor.MarkBlockDirty(be.Pos, () => render.ShouldRender = true);
     }
 }
Beispiel #8
0
 // Token: 0x0600114F RID: 4431 RVA: 0x00065644 File Offset: 0x00063844
 private void PositionGrenadeAiming(AnimationMetaData metaData, int frame)
 {
     AnimationMetaData.AnimationData animationData = metaData.FindData("#grenade");
     if (animationData != null)
     {
         Vector3 positionAtFrame = animationData.GetPositionAtFrame(frame);
         this.m_grenadeAiming.transform.position = this.m_sein.PlatformBehaviour.Visuals.Sprite.transform.TransformPoint(positionAtFrame);
     }
 }
        public AiTaskGotoEntity(EntityAgent entity, Entity target) : base(entity)
        {
            targetEntity = target;

            animMeta = new AnimationMetaData()
            {
                Code           = "walk",
                Animation      = "walk",
                AnimationSpeed = 1f
            }.Init();
        }
 public void StartAnimation(AnimationMetaData meta)
 {
     if (!activeAnimationsByAnimCode.ContainsKey(meta.Code))
     {
         stopRenderTriggered = false;
         activeAnimationsByAnimCode[meta.Code] = meta;
         if (renderer != null)
         {
             api.World.BlockAccessor.MarkBlockDirty(be.Pos, () => renderer.ShouldRender = true);
         }
     }
 }
Beispiel #11
0
 public void Init()
 {
     if (Animations != null)
     {
         for (int i = 0; i < Animations.Length; i++)
         {
             AnimationMetaData animMeta = Animations[i];
             if (animMeta.Animation != null)
             {
                 AnimationsByMetaCode[animMeta.Code] = animMeta;
             }
         }
     }
 }
        public override bool StartAnimation(AnimationMetaData animdata)
        {
            if (Personality == "formal" || Personality == "rowdy" || Personality == "lazy")
            {
                StopAnimation(Personality + "idle");
                StopAnimation(Personality + "idle2");
            }

            if (PersonalizedAnimations.Contains(animdata.Animation.ToLowerInvariant()))
            {
                animdata           = animdata.Clone();
                animdata.Animation = Personality + animdata.Animation;
                animdata.Code      = animdata.Animation;
                animdata.CodeCrc32 = AnimationMetaData.GetCrc32(animdata.Code);
            }

            return(base.StartAnimation(animdata));
        }
        public virtual void LoadConfig(JsonObject taskConfig, JsonObject aiConfig)
        {
            if (taskConfig["animation"].Exists)
            {
                animMeta = new AnimationMetaData()
                {
                    Code           = taskConfig["animation"].AsString()?.ToLowerInvariant(),
                    Animation      = taskConfig["animation"].AsString()?.ToLowerInvariant(),
                    AnimationSpeed = taskConfig["animationSpeed"].AsFloat(1f)
                }.Init();
            }

            if (taskConfig["sound"] != null)
            {
                sound        = taskConfig["sound"].AsString();
                soundRange   = taskConfig["soundRange"].AsFloat(16);
                soundStartMs = taskConfig["soundStartMs"].AsInt(0);
            }
        }
        private void SetAnimation(string animCode, float speed)
        {
            AnimationMetaData animMeta = null;

            if (!ActiveAnimationsByAnimCode.TryGetValue(animCode, out animMeta))
            {
                animMeta = new AnimationMetaData()
                {
                    Code           = animCode,
                    Animation      = animCode,
                    AnimationSpeed = speed,
                };

                ActiveAnimationsByAnimCode.Clear();
                ActiveAnimationsByAnimCode[animMeta.Animation] = animMeta;
                return;
            }

            animMeta.AnimationSpeed = speed;
        }
        private void SetAnimation(string animCode, float speed)
        {
            AnimationMetaData animMeta;

            if (!AnimManager.ActiveAnimationsByAnimCode.TryGetValue(animCode, out animMeta))
            {
                animMeta = new AnimationMetaData()
                {
                    Code           = animCode,
                    Animation      = animCode,
                    AnimationSpeed = speed,
                };

                AnimManager.ActiveAnimationsByAnimCode.Clear();
                AnimManager.ActiveAnimationsByAnimCode[animMeta.Animation] = animMeta;
                return;
            }

            animMeta.AnimationSpeed = speed;
            UpdateDebugAttributes();
        }
        public override void LoadConfig(JsonObject taskConfig, JsonObject aiConfig)
        {
            base.LoadConfig(taskConfig, aiConfig);

            if (taskConfig["eatSound"] != null)
            {
                string eatsoundstring = taskConfig["eatSound"].AsString(null);
                if (eatsoundstring != null)
                {
                    eatSound = new AssetLocation(eatsoundstring).WithPathPrefix("sounds/");
                }
            }

            if (taskConfig["movespeed"] != null)
            {
                moveSpeed = taskConfig["movespeed"].AsFloat(0.02f);
            }

            if (taskConfig["eatTime"] != null)
            {
                eatTime = taskConfig["eatTime"].AsFloat(1.5f);
            }

            if (taskConfig["doConsumePortion"] != null)
            {
                doConsumePortion = taskConfig["doConsumePortion"].AsBool(true);
            }

            if (taskConfig["eatanimation"].Exists)
            {
                nlAnimMeta = new AnimationMetaData()
                {
                    Code           = taskConfig["eatanimation"].AsString()?.ToLowerInvariant(),
                    Animation      = taskConfig["eatanimation"].AsString()?.ToLowerInvariant(),
                    AnimationSpeed = taskConfig["eatanimationspeed"].AsFloat(1f)
                }.Init();
            }
        }
Beispiel #17
0
        private void OnClientMessage(IPlayer fromPlayer, NetworkAnimationSit networkMessage)
        {
            serverAPI.Logger.Debug("Server: " + fromPlayer.PlayerName + " is sitting: " + networkMessage.isSitting);

            if (networkMessage.isSitting)
            {
                AnimationMetaData data = new AnimationMetaData()
                {
                    Animation = "sitflooridle", Code = "sitflooridle", AnimationSpeed = 1.0f, BlendMode = EnumAnimationBlendMode.Add, SupressDefaultAnimation = true, EaseOutSpeed = 10000, EaseInSpeed = 10000
                }.Init();
                fromPlayer.Entity.AnimManager.StartAnimation(data);
                fromPlayer.Entity.AnimManager.AnimationsDirty = true;
            }
            else
            {
                fromPlayer.Entity.AnimManager.StopAnimation("sitflooridle");
                fromPlayer.Entity.AnimManager.AnimationsDirty = true;
            }

            serverChannel.BroadcastPacket(new NetworkAnimationSit()
            {
                isSitting = networkMessage.isSitting, playerUID = networkMessage.playerUID
            });
        }
Beispiel #18
0
        private void OnServerMessage(NetworkAnimationSit networkMessage)
        {
            IPlayer sittingPlayer = clientAPI.World.PlayerByUid(networkMessage.playerUID);

            if (sittingPlayer == null)
            {
                return;
            }

            clientAPI.Logger.Debug("Client: " + sittingPlayer.PlayerName + " is sitting: " + networkMessage.isSitting);

            if (networkMessage.isSitting)
            {
                AnimationMetaData data = new AnimationMetaData()
                {
                    Animation = "sitflooridle", Code = "sitflooridle", AnimationSpeed = 1.0f, BlendMode = EnumAnimationBlendMode.Add, SupressDefaultAnimation = true, EaseOutSpeed = 10000, EaseInSpeed = 10000
                }.Init();
                sittingPlayer.Entity.AnimManager.StartAnimation(data);
            }
            else
            {
                sittingPlayer.Entity.AnimManager.StopAnimation("sitflooridle");
            }
        }
        public override void LoadConfig(JsonObject taskConfig, JsonObject aiConfig)
        {
            base.LoadConfig(taskConfig, aiConfig);

            if (taskConfig["movespeed"] != null)
            {
                moveSpeed = taskConfig["movespeed"].AsFloat(0.02f);
            }

            if (taskConfig["mineTime"] != null)
            {
                mineTime = taskConfig["mineTime"].AsFloat(1.5f);
            }

            if (taskConfig["mineAnimation"].Exists)
            {
                mineAnimMeta = new AnimationMetaData()
                {
                    Code           = taskConfig["mineAnimation"].AsString()?.ToLowerInvariant(),
                    Animation      = taskConfig["mineAnimation"].AsString()?.ToLowerInvariant(),
                    AnimationSpeed = taskConfig["mineAnimationSpeed"].AsFloat(1f)
                }.Init();
            }
        }
Beispiel #20
0
        public override void LoadConfig(JsonObject taskConfig, JsonObject aiConfig)
        {
            base.LoadConfig(taskConfig, aiConfig);

            if (taskConfig["eatSound"] != null)
            {
                string eatsoundstring = taskConfig["eatSound"].AsString(null);
                if (eatsoundstring != null)
                {
                    eatSound = new AssetLocation(eatsoundstring).WithPathPrefix("sounds/");
                }
            }

            if (taskConfig["movespeed"] != null)
            {
                moveSpeed = taskConfig["movespeed"].AsFloat(0.02f);
            }

            if (taskConfig["searchPlayerInv"] != null)
            {
                searchPlayerInv = taskConfig["searchPlayerInv"].AsBool(false);
            }

            if (taskConfig["eatTime"] != null)
            {
                eatTime = taskConfig["eatTime"].AsFloat(1.5f);
            }

            if (taskConfig["doConsumePortion"] != null)
            {
                doConsumePortion = taskConfig["doConsumePortion"].AsBool(true);
            }

            if (taskConfig["eatLooseItems"] != null)
            {
                eatLooseItems = taskConfig["eatLooseItems"].AsBool(true);
            }

            if (taskConfig["playEatAnimForLooseItems"] != null)
            {
                playEatAnimForLooseItems = taskConfig["playEatAnimForLooseItems"].AsBool(true);
            }

            if (taskConfig["eatItemCategories"] != null)
            {
                foreach (var val in taskConfig["eatItemCategories"].AsArray <EnumFoodCategory>(new EnumFoodCategory[0]))
                {
                    eatItemCategories.Add(val);
                }
            }

            if (taskConfig["eatItemCodes"] != null)
            {
                foreach (var val in taskConfig["eatItemCodes"].AsArray(new AssetLocation[0]))
                {
                    eatItemCodes.Add(val);
                }
            }

            if (taskConfig["eatAnimation"].Exists)
            {
                eatAnimMeta = new AnimationMetaData()
                {
                    Code           = taskConfig["eatAnimation"].AsString()?.ToLowerInvariant(),
                    Animation      = taskConfig["eatAnimation"].AsString()?.ToLowerInvariant(),
                    AnimationSpeed = taskConfig["eatAnimationSpeed"].AsFloat(1f)
                }.Init();
            }

            if (taskConfig["eatAnimationLooseItems"].Exists)
            {
                eatAnimMetaLooseItems = new AnimationMetaData()
                {
                    Code           = taskConfig["eatAnimationLooseItems"].AsString()?.ToLowerInvariant(),
                    Animation      = taskConfig["eatAnimationLooseItems"].AsString()?.ToLowerInvariant(),
                    AnimationSpeed = taskConfig["eatAnimationSpeedLooseItems"].AsFloat(1f)
                }.Init();
            }

            // Fetch the entity's diet from its JSON durin initialize as this is a potentially slow operation (for most entities diet will be null)
            entityDiet = entity.Properties.Attributes?["blockDiet"]?.AsArray <string>();
        }
        private void OnClientGameTick(float dt)
        {
            if (ownBlock == null || Api?.World == null || !canTeleport || !Activated)
            {
                return;
            }

            if (Api.World.ElapsedMilliseconds - somebodyIsTeleportingReceivedTotalMs > 6000)
            {
                somebodyIsTeleporting = false;
            }

            HandleSoundClient(dt);

            bool selfInside   = (Api.World.ElapsedMilliseconds > 100 && Api.World.ElapsedMilliseconds - lastCollideMsOwnPlayer < 100);
            bool playerInside = selfInside || somebodyIsTeleporting;
            bool active       = animUtil.activeAnimationsByAnimCode.ContainsKey("teleport");

            if (!selfInside && playerInside)
            {
                manager.lastTranslocateCollideMsOtherPlayer = Api.World.ElapsedMilliseconds;
            }

            SimpleParticleProperties currentParticles = active ?
                                                        ownBlock.insideParticles :
                                                        ownBlock.idleParticles
            ;

            if (playerInside)
            {
                var meta = new AnimationMetaData()
                {
                    Animation = "teleport", Code = "teleport", AnimationSpeed = 1, EaseInSpeed = 1, EaseOutSpeed = 2, Weight = 1, BlendMode = EnumAnimationBlendMode.Add
                };
                animUtil.StartAnimation(meta);
                animUtil.StartAnimation(new AnimationMetaData()
                {
                    Animation = "idle", Code = "idle", AnimationSpeed = 1, EaseInSpeed = 1, EaseOutSpeed = 1, Weight = 1, BlendMode = EnumAnimationBlendMode.Average
                });
            }
            else
            {
                animUtil.StopAnimation("teleport");
            }


            if (animUtil.activeAnimationsByAnimCode.Count > 0 && Api.World.ElapsedMilliseconds - lastCollideMsOwnPlayer > 10000 && Api.World.ElapsedMilliseconds - manager.lastTranslocateCollideMsOtherPlayer > 10000)
            {
                animUtil.StopAnimation("idle");
            }


            //int color = temporalGearStack.Collectible.GetRandomColor(api as ICoreClientAPI, temporalGearStack); - not working o.O

            int r = 53;
            int g = 221;
            int b = 172;

            currentParticles.Color = (r << 16) | (g << 8) | (b << 0) | (50 << 24);

            currentParticles.AddPos.Set(0, 0, 0);
            currentParticles.BlueEvolve    = null;
            currentParticles.RedEvolve     = null;
            currentParticles.GreenEvolve   = null;
            currentParticles.MinSize       = 0.1f;
            currentParticles.MaxSize       = 0.2f;
            currentParticles.SizeEvolve    = null;
            currentParticles.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.LINEAR, 100f);


            bool rot = Block.Variant["side"] == "east" || Block.Variant["side"] == "west";

            particleAngle = active ? particleAngle + 5 * dt : 0;


            double dx = GameMath.Cos(particleAngle + (rot ? GameMath.PIHALF : 0)) * 0.35f;
            double dy = 1.9 + Api.World.Rand.NextDouble() * 0.2;
            double dz = GameMath.Sin(particleAngle + (rot ? GameMath.PIHALF : 0)) * 0.35f;

            currentParticles.LifeLength = GameMath.Sqrt(dx * dx + dz * dz) / 10;
            currentParticles.MinPos.Set(posvec.X + dx, posvec.Y + dy, posvec.Z + dz);
            currentParticles.MinVelocity.Set(-(float)dx / 2, -1 - (float)Api.World.Rand.NextDouble() / 2, -(float)dz / 2);
            currentParticles.MinQuantity = active ? 3 : 0.25f;
            currentParticles.AddVelocity.Set(0, 0, 0);
            currentParticles.AddQuantity = 0.5f;

            Api.World.SpawnParticles(currentParticles);

            currentParticles.MinPos.Set(posvec.X - dx, posvec.Y + dy, posvec.Z - dz);
            currentParticles.MinVelocity.Set((float)dx / 2, -1 - (float)Api.World.Rand.NextDouble() / 2, (float)dz / 2);
            Api.World.SpawnParticles(currentParticles);
        }
        public override void LoadConfig(JsonObject taskConfig, JsonObject aiConfig)
        {
            base.LoadConfig(taskConfig, aiConfig);

            if (taskConfig["eatSound"] != null)
            {
                string eatsoundstring = taskConfig["eatSound"].AsString(null);
                if (eatsoundstring != null)
                {
                    eatSound = new AssetLocation(eatsoundstring).WithPathPrefix("sounds/");
                }
            }

            if (taskConfig["movespeed"] != null)
            {
                moveSpeed = taskConfig["movespeed"].AsFloat(0.02f);
            }

            if (taskConfig["searchPlayerInv"] != null)
            {
                searchPlayerInv = taskConfig["searchPlayerInv"].AsBool(false);
            }

            if (taskConfig["eatTime"] != null)
            {
                eatTime = taskConfig["eatTime"].AsFloat(1.5f);
            }

            if (taskConfig["doConsumePortion"] != null)
            {
                doConsumePortion = taskConfig["doConsumePortion"].AsBool(true);
            }

            if (taskConfig["eatLooseItems"] != null)
            {
                eatLooseItems = taskConfig["eatLooseItems"].AsBool(true);
            }

            if (taskConfig["playEatAnimForLooseItems"] != null)
            {
                playEatAnimForLooseItems = taskConfig["playEatAnimForLooseItems"].AsBool(true);
            }

            if (taskConfig["eatItemCategories"] != null)
            {
                foreach (var val in taskConfig["eatItemCategories"].AsArray <EnumFoodCategory>(new EnumFoodCategory[0]))
                {
                    eatItemCategories.Add(val);
                }
            }

            if (taskConfig["eatItemCodes"] != null)
            {
                foreach (var val in taskConfig["eatItemCodes"].AsArray(new AssetLocation[0]))
                {
                    eatItemCodes.Add(val);
                }
            }

            if (taskConfig["eatAnimation"].Exists)
            {
                eatAnimMeta = new AnimationMetaData()
                {
                    Code           = taskConfig["eatAnimation"].AsString()?.ToLowerInvariant(),
                    Animation      = taskConfig["eatAnimation"].AsString()?.ToLowerInvariant(),
                    AnimationSpeed = taskConfig["eatAnimationSpeed"].AsFloat(1f)
                }.Init();
            }

            if (taskConfig["eatAnimationLooseItems"].Exists)
            {
                eatAnimMetaLooseItems = new AnimationMetaData()
                {
                    Code           = taskConfig["eatAnimationLooseItems"].AsString()?.ToLowerInvariant(),
                    Animation      = taskConfig["eatAnimationLooseItems"].AsString()?.ToLowerInvariant(),
                    AnimationSpeed = taskConfig["eatAnimationSpeedLooseItems"].AsFloat(1f)
                }.Init();
            }
        }
        public override void OnReceivedServerAnimations(int[] activeAnimations, int activeAnimationsCount, float[] activeAnimationSpeeds)
        {
            // We control glide and fly animations entirely client side

            if (activeAnimationsCount == 0)
            {
                AnimManager.ActiveAnimationsByAnimCode.Clear();
                AnimManager.StartAnimation("fly");
            }

            string active = "";

            bool found = false;

            for (int i = 0; i < activeAnimationsCount; i++)
            {
                int crc32 = activeAnimations[i];
                for (int j = 0; j < Properties.Client.LoadedShape.Animations.Length; j++)
                {
                    Animation anim = Properties.Client.LoadedShape.Animations[j];
                    int       mask = ~(1 << 31); // Because I fail to get the sign bit transmitted correctly over the network T_T
                    if ((anim.CodeCrc32 & mask) == (crc32 & mask))
                    {
                        if (AnimManager.ActiveAnimationsByAnimCode.ContainsKey(anim.Code))
                        {
                            break;
                        }
                        if (anim.Code == "glide" || anim.Code == "fly")
                        {
                            continue;
                        }

                        string code = anim.Code == null?anim.Name.ToLowerInvariant() : anim.Code;

                        active += ", " + code;
                        AnimationMetaData animmeta;
                        Properties.Client.AnimationsByMetaCode.TryGetValue(code, out animmeta);

                        if (animmeta == null)
                        {
                            animmeta = new AnimationMetaData()
                            {
                                Code      = code,
                                Animation = code,
                                CodeCrc32 = anim.CodeCrc32
                            };
                        }

                        animmeta.AnimationSpeed = activeAnimationSpeeds[i];

                        AnimManager.ActiveAnimationsByAnimCode[anim.Code] = animmeta;

                        found = true;
                    }
                }
            }

            if (found)
            {
                AnimManager.StopAnimation("fly");
                AnimManager.StopAnimation("glide");

                (Properties.Client.Renderer as EntityShapeRenderer).AddRenderFlags    = EnumWindBitModeMask.Bend;
                (Properties.Client.Renderer as EntityShapeRenderer).WindWaveIntensity = WatchedAttributes.GetDouble("windWaveIntensity");
            }
            else
            {
                (Properties.Client.Renderer as EntityShapeRenderer).AddRenderFlags = 0;
            }
        }
Beispiel #24
0
 public override void StartAnimation(AnimationMetaData animdata)
 {
     base.StartAnimation(animdata);
 }