Esempio n. 1
0
        public override void Initialize(EntityProperties properties, ICoreAPI api, long chunkindex3d)
        {
            base.Initialize(properties, api, chunkindex3d);

            if (Itemstack == null || !Itemstack.ResolveBlockOrItem(World))
            {
                Die();
                this.Itemstack = null;
                return;
            }

            // If attribute was modified and resent to client, make sure we still have the resolved thing in memory
            WatchedAttributes.RegisterModifiedListener("itemstack", () => {
                if (Itemstack != null && Itemstack.Collectible == null)
                {
                    Itemstack.ResolveBlockOrItem(World);
                }
                Slot.Itemstack = Itemstack;
            });


            itemSpawnedMilliseconds = World.ElapsedMilliseconds;
            Swimming = FeetInLiquid = World.BlockAccessor.GetBlock(Pos.AsBlockPos).IsLiquid();

            tmpPos.Set(Pos.XInt, Pos.YInt, Pos.ZInt);
            windLoss = World.BlockAccessor.GetDistanceToRainFall(tmpPos) / 4f;
        }
Esempio n. 2
0
        public override void Initialize(EntityProperties properties, ICoreAPI api, long InChunkIndex3d)
        {
            // Temporary code for VS 1.15 dev team to remove previously created "land" salmon which don't have the correct entity
            if (properties.Habitat == EnumHabitat.Underwater && !(this.GetType().Name == "EntityFish"))
            {
                this.Alive = false;
            }

            base.Initialize(properties, api, InChunkIndex3d);

            if (World.Side == EnumAppSide.Server)
            {
                servercontrols = controls;
            }

            WatchedAttributes.RegisterModifiedListener("mountedOn", updateMountedState);

            if (WatchedAttributes["mountedOn"] != null)
            {
                MountedOn = World.ClassRegistry.CreateMountable(WatchedAttributes["mountedOn"] as TreeAttribute);
                if (MountedOn != null)
                {
                    TryMount(MountedOn);
                }
            }
        }
        public override void Initialize(EntityProperties properties, ICoreAPI api, long InChunkIndex3d)
        {
            base.Initialize(properties, api, InChunkIndex3d);

            if (api.Side == EnumAppSide.Client)
            {
                WatchedAttributes.RegisterModifiedListener("sitHeight", () =>
                {
                    (Properties.Client.Renderer as EntityShapeRenderer).WindWaveIntensity = WatchedAttributes.GetDouble("sitHeight");
                });
            }
        }
        public override void Initialize(EntityProperties properties, ICoreAPI api, long InChunkIndex3d)
        {
            base.Initialize(properties, api, InChunkIndex3d);

            if (api.Side == EnumAppSide.Server)
            {
                GetBehavior <EntityBehaviorTaskAI>().taskManager.OnTaskStarted += EntityGlowingAgent_OnTaskStarted;
            }
            else
            {
                WatchedAttributes.RegisterModifiedListener("aggroTime", () => { aggroTime = WatchedAttributes.GetFloat("aggroTime"); });
            }

            aggroTime = WatchedAttributes.GetFloat("aggroTime");
        }
Esempio n. 5
0
        public override void Initialize(EntityProperties properties, ICoreAPI api, long InChunkIndex3d)
        {
            base.Initialize(properties, api, InChunkIndex3d);

            if (api.Side == EnumAppSide.Server)
            {
                GetBehavior <EntityBehaviorTaskAI>().TaskManager.OnTaskStarted += EntityGlowingAgent_OnTaskStarted;
            }
            else
            {
                WatchedAttributes.RegisterModifiedListener("aggroTime", () => { aggroTime = WatchedAttributes.GetFloat("aggroTime"); });
            }

            aggroTime       = WatchedAttributes.GetFloat("aggroTime");
            lightHsv        = properties.Attributes["lightHsv"].AsObject <byte[]>(new byte[] { 10, 5, 10 });
            onlyWhenAggroed = properties.Attributes["onlyWhenAggroed"].AsBool(true);
        }
Esempio n. 6
0
        public override void Initialize(EntityProperties properties, ICoreAPI api, long InChunkIndex3d)
        {
            base.Initialize(properties, api, InChunkIndex3d);

            if (gearInv == null)
            {
                gearInv = new InventoryGeneric(17, "gear-" + EntityId, api, onNewSlot);
                gearInv.SlotModified += GearInv_SlotModified;
            }

            if (api.Side == EnumAppSide.Client)
            {
                WatchedAttributes.RegisterModifiedListener("inventory", readInventoryFromAttributes);
            }

            readInventoryFromAttributes();
        }
        public override void Initialize(EntityProperties properties, ICoreAPI api, long InChunkIndex3d)
        {
            base.Initialize(properties, api, InChunkIndex3d);

            if (api.Side == EnumAppSide.Client)
            {
                WatchedAttributes.RegisterModifiedListener("windWaveIntensity", () =>
                {
                    (Properties.Client.Renderer as EntityShapeRenderer).WindWaveIntensity = WatchedAttributes.GetDouble("windWaveIntensity");
                });
            }


            ClimateCondition conds = api.World.BlockAccessor.GetClimateAt(Pos.AsBlockPos, EnumGetClimateMode.NowValues);

            if (conds != null && conds.Temperature < 0)
            {
                Die(EnumDespawnReason.Removed);
            }
        }