public override void Initialize(EntityProperties properties, JsonObject typeAttributes) { api = entity.World.Api; blockAccess = api.World.GetCachingBlockAccessor(false, false); tempTree = entity.WatchedAttributes.GetTreeAttribute("bodyTemp"); NormalBodyTemperature = typeAttributes["defaultBodyTemperature"].AsFloat(37); if (tempTree == null) { entity.WatchedAttributes.SetAttribute("bodyTemp", tempTree = new TreeAttribute()); CurBodyTemperature = NormalBodyTemperature + 4; // Run this every time a entity spawns so it doesnt freeze while unloaded / offline BodyTempUpdateTotalHours = api.World.Calendar.TotalHours; LastWetnessUpdateTotalHours = api.World.Calendar.TotalHours; return; } // Run this every time a entity spawns so it doesnt freeze while unloaded / offline BodyTempUpdateTotalHours = api.World.Calendar.TotalHours; LastWetnessUpdateTotalHours = api.World.Calendar.TotalHours; bodyTemperatureResistance = entity.World.Config.GetString("bodyTemperatureResistance").ToFloat(0); }
public override void Start(ICoreAPI api) { base.Start(api); this.api = api; api.Event.ChunkDirty += Event_ChunkDirty; blockAccess = api.World.GetCachingBlockAccessor(false, false); }
public AiTaskPerch(EntityAgent entity) : base(entity) { blockAccess = ((ICoreServerAPI)entity.Api).WorldManager.GetCachingBlockAccessor(true, true); fc = new FlightControl(entity); }
public FlightControl(EntityAgent entity) { this.entity = entity; blockAccess = ((ICoreServerAPI)entity.Api).WorldManager.GetCachingBlockAccessor(true, true); }
public override void Initialize(EntityProperties properties, JsonObject attributes) { base.Initialize(properties, attributes); blockCheck = entity.World.GetCachingBlockAccessor(false, false); if (attributes.IsTrue("relaxed")) { relaxed = true; } if (attributes.IsTrue("nochest")) { nochest = true; } if (attributes.IsTrue("nobarrel")) { nobarrel = true; } if (attributes.IsTrue("invLocked")) { invLocked = true; } if (attributes["restrictItem"] != null) { JsonItemStack prestack = attributes["restrictItem"].AsObject <JsonItemStack>(); if (prestack != null) { prestack.Resolve(entity.World, "Locust Program"); if (prestack.ResolvedItemstack != null) { maintree.SetItemstack("workStack", prestack.ResolvedItemstack); maintree.SetBool("restrictItem", true); restricted = true; } } } ITreeAttribute area = maintree.GetTreeAttribute("workArea"); ITreeAttribute box = maintree.GetTreeAttribute("workChest"); ITreeAttribute barrel = maintree.GetTreeAttribute("workBarrel"); workStack = maintree.GetItemstack("workStack"); workStack?.ResolveBlockOrItem(entity.World); if (entity.Api.Side == EnumAppSide.Client && maintree.GetBool("restrictItem")) { restricted = true; } if (area != null) { workArea = cuboiddFromTree(area); } if (box != null) { workChest = new BlockPos(box.GetInt("x"), box.GetInt("y"), box.GetInt("z")); } if (barrel != null) { workBarrel = new BlockPos(barrel.GetInt("x"), barrel.GetInt("y"), barrel.GetInt("z")); } ITreeAttribute tree = maintree["workInv"] as ITreeAttribute; if (tree != null) { workInv.FromTreeAttributes(tree); } }
public override void Dispose() { blockAccess?.Dispose(); blockAccess = null; }
public AStar(ICoreServerAPI api) { this.api = api; blockAccess = api.World.GetCachingBlockAccessor(true, true); }
public AStarClient(ICoreClientAPI api) { this.api = api; blockAccess = api.World.GetCachingBlockAccessor(true, true); }