public override void PostUpdate(Timestep timestep, EntityUniverseFacade entityUniverseFacade) { if (_done) { entityUniverseFacade.RemoveEntity(_entity.Id); CanDispose = true; Dispose(); } }
public override void PostUpdate(Timestep timestep, EntityUniverseFacade universe) { if (_done) { universe.RemoveEntity(Entity.Id); } }
public override void Update(Timestep timestep, EntityUniverseFacade entityUniverseFacade) { if (TilePower == null) { return; } Universe = entityUniverseFacade; if (entityUniverseFacade.ReadTile(Location, TileAccessFlags.SynchronousWait, out var tile)) { var config = GameContext.TileDatabase.GetTileConfiguration(Tile); if (config.Components.Select <ChargeableComponent>().Any() && tile.Configuration.Code != "staxel.tile.Sky") { TilePower.GetPowerFromComponent(config.Components.Select <ChargeableComponent>().First()); } else { var itemBlob = BlobAllocator.Blob(true); itemBlob.SetString("kind", "staxel.item.Placer"); itemBlob.SetString("tile", Tile); var item = GameContext.ItemDatabase.SpawnItemStack(itemBlob, null); ItemEntityBuilder.SpawnDroppedItem(Entity, entityUniverseFacade, item, Entity.Physics.Position, new Vector3D(0, 1, 0), Vector3D.Zero, SpawnDroppedFlags.None); entityUniverseFacade.RemoveEntity(Entity.Id); return; } Cycle.RunCycle(RunCycle); } }
public virtual void Update(Timestep timestep, EntityUniverseFacade entityUniverseFacade, bool inherited = false) { if (TilePower == null) { return; } if (entityUniverseFacade.ReadTile(Location, TileAccessFlags.SynchronousWait, out var tile)) { if (tile.Configuration.Components.Select <ChargeableComponent>().Any()) { TilePower.GetPowerFromComponent(tile.Configuration.Components.Select <ChargeableComponent>().First()); } else { entityUniverseFacade.RemoveEntity(Entity.Id); return; } } Universe = entityUniverseFacade; if (!inherited) { Cycle.RunCycle(RunCycle); } }
public override void PostUpdate(Timestep timestep, EntityUniverseFacade entityUniverseFacade) { if (!entityUniverseFacade.TryGetEntity(Owner, out _)) { Entity.SetRemoved(); entityUniverseFacade.RemoveEntity(Entity.Id); } }
public override void PostUpdate(Timestep timestep, EntityUniverseFacade universe) { //If this has been set. Remove this entity. if (this._isRemoved) { universe.RemoveEntity(Entity.Id); } }
public override void PostUpdate(Timestep timestep, EntityUniverseFacade entityUniverseFacade) { if (_remove) { Entity.SetRemoved(); entityUniverseFacade.RemoveEntity(Entity.Id); } }
public override void PreUpdate(Timestep timestep, EntityUniverseFacade universe) { base.PreUpdate(timestep, universe); if (universe.ReadTile(Location, TileAccessFlags.SynchronousWait, out var tile)) { if (tile.Configuration.Code == "staxel.tile.Sky") { CycleHook.RemoveCycle(Location); universe.RemoveEntity(Entity.Id); } else { Cycle.RunCycle(RunCycle); } } }
public override void PostUpdate(Timestep timestep, EntityUniverseFacade universe) { Tile result; if (!universe.ReadTile(Location, TileAccessFlags.None, out result)) { return; } if (result.Configuration != _configuration) { if (result.Configuration.CanonicalConfiguration == _configuration.CanonicalConfiguration) { _configuration = result.Configuration; _needsStore = true; } else { universe.RemoveEntity(Entity.Id); } } }
public override void Control(Entity entity, EntityUniverseFacade facade, ControlState main, ControlState alt) { //if (alt.DownClick) { // if (_mode == Mode.PickUp) { // _mode = Mode.Power; // } else { // _mode = Mode.PickUp; // } // entity.Inventory.ItemStoreNeedsStorage(); //} if (!main.DownClick) { return; } if (_mode == Mode.Rotate) { if (entity.PlayerEntityLogic.LookingAtTile(out var target, out _)) { if (facade.ReadTile(target, TileAccessFlags.SynchronousWait, out var tile)) { facade.PlaceTile(entity, target, tile.Configuration.MakeTile(tile.Configuration.BuildRotationVariant(tile.Configuration.Rotation(0))), TileAccessFlags.SynchronousWait); } } } else if (_mode == Mode.PickUp) { if (entity.PlayerEntityLogic.LookingAtTile(out var target, out _)) { if (facade.ReadTile(target, TileAccessFlags.SynchronousWait, out var tile)) { if (tile.Configuration.Components.Contains <WrenchableComponent>()) { if (facade.TryFetchTileStateEntityLogic(target, TileAccessFlags.SynchronousWait, out var logic)) { if (logic is ChargeableTileStateEntityLogic chargeable) { if (facade.TryGetEntity(chargeable.GetOwner(), out var owner)) { if (owner.Logic is ITileWithPower tileWithPower) { tileWithPower.ActiveNameTag = false; } facade.RemoveEntity(chargeable.GetOwner()); } facade.RemoveEntity(chargeable.Entity.Id); } } var destructor = DestructionEntityBuilder.Spawn(entity, target, facade, ""); destructor.AttemptPickup(); destructor.EnqueueDeferredDestructionQueue(facade.Step, target, tile); } } } } }
public override void Control(Entity entity, EntityUniverseFacade facade, ControlState main, ControlState alt) { if (!main.DownClick && !alt.DownClick) { return; } if (main.DownClick) { if (entity.PlayerEntityLogic.LookingAtTile(out var target, out _)) { if (facade.AnyInnerCableEntitiesInTile(target, out var entities)) { foreach (var lEntity in entities) { var itemBlob = BlobAllocator.Blob(true); itemBlob.SetString("code", ((InnerCableTileEntityLogic)lEntity.Logic).Tile); var item = GameContext.ItemDatabase.SpawnItemStack(itemBlob, null); if (item.IsNull()) { itemBlob.Delete("code"); itemBlob.SetString("kind", "staxel.item.Placer"); itemBlob.SetString("tile", ((InnerCableTileEntityLogic)lEntity.Logic).Tile); item = GameContext.ItemDatabase.SpawnItemStack(itemBlob, null); } ItemEntityBuilder.SpawnDroppedItem(entity, facade, item, target.ToVector3D(), Vector3D.Zero, Vector3D.Zero, SpawnDroppedFlags.AttemptPickup); facade.RemoveEntity(lEntity.Id); } } else { if (_targetCode == "nimbusfox.powerapi.verb.none") { var notification = GameContext.NotificationDatabase.CreateNotificationFromCode( "nimbusfox.powerapi.notifications.noCableSelected", facade.Step, new NotificationParams(), true); entity.PlayerEntityLogic.ShowNotification(notification); return; } if (!entity.Inventory.HasItemWithCode(_targetCode)) { var nparams = new NotificationParams(1); nparams.SetTranslation(0, _targetCode + ".name"); var notification = GameContext.NotificationDatabase.CreateNotificationFromCode( "nimbusfox.powerapi.notifications.noCable", facade.Step, nparams, true); entity.PlayerEntityLogic.ShowNotification(notification); return; } if (facade.ReadTile(target, TileAccessFlags.SynchronousWait, out var tile)) { if (!tile.Configuration.Components.Select <ChargeableComponent>().Any()) { var config = BlobAllocator.Blob(true); config.SetString("tile", _targetCode); InnerCableTileEntityBuilder.Spawn(target, config, facade); entity.Inventory.ConsumeItem(new ItemStack(entity.Inventory.GetItemStack(_slot).Item, 1)); } } } } } if (alt.DownClick) { var orig = _targetCode; var looped = false; loop: if (_slot + 1 >= entity.Inventory.SlotCount()) { _slot = 0; } for (var i = _slot; i < entity.Inventory.SlotCount(); i++) { var current = entity.Inventory.GetItemStack(i); if (current.IsNull()) { continue; } if (current.Item.Configuration.Components.Select <CableComponent>().Any()) { _slot = i; _targetCode = current.Item.GetItemCode(); break; } } if (orig == _targetCode) { if (!looped) { looped = true; _slot = 0; goto loop; } _targetCode = "nimbusfox.powerapi.verb.none"; } } entity.Inventory.ItemStoreNeedsStorage(); }