/// <summary> /// Adds an entity to this Virtual Machine. /// </summary> /// <param name="entity">The entity to add.</param> public void AddEntity(VMEntity entity) { this.Entities.Add(entity); entity.ObjectID = ObjectId++; ObjectsById.Add(entity.ObjectID, entity); entity.Init(Context); }
public void DrawActionsOf(VMEntity obj) { objNameLabel.Text = "Active Object: " + obj.ToString(); actionView.Items.Clear(); for (int i = 0; i < obj.Thread.Queue.Count; i++) { actionView.Items.Add(new ListViewItem(obj.Thread.Queue[i].Name, (i == 0) ? 0 : 1)); } }
public Simantics(VM vm) { this.vm = vm; InitializeComponent(); ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar); aq = new ActionQueue(); aq.Show(); aq.target = ActiveEntity; }
public static void AddToObjList(List<VMEntity> list, VMEntity entity) { if (list.Count == 0) { list.Add(entity); return; } int id = entity.ObjectID-1; int max = list.Count-1; int min = 0; while (max-1>min) { int mid = (max+min) / 2; int nid = list[mid].ObjectID; if (id < nid) max = mid; else min = mid; } list.Insert((list[min].ObjectID>id)?min:((list[max].ObjectID > id)?max:max+1), entity); }
/// <summary> /// Creates a new UILotControl instance. /// </summary> /// <param name="vm">A SimAntics VM instance.</param> /// <param name="World">A World instance.</param> public UILotControl(TSO.Simantics.VM vm, World World) { this.vm = vm; this.World = World; ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar); MouseEvt = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0, GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight), OnMouse); testimg = new UIImage(); testimg.X = 20; testimg.Y = 20; this.Add(testimg); Queue = new UIInteractionQueue(ActiveEntity); this.Add(Queue); }
public void PushUserInteraction(int interaction,VMEntity caller,VMContext context) { var Action = TreeTable.InteractionByIndex[(uint)interaction]; ushort ActionID = Action.ActionFunction; var function = GetBHAVWithOwner(ActionID,context); var routine = context.VM.Assemble(function.bhav); caller.Thread.EnqueueAction( new TSO.Simantics.engine.VMQueuedAction { Callee = this, CodeOwner = function.owner, Routine = routine, Name = TreeTableStrings.GetString((int)Action.TTAIndex), StackObject = this, InteractionNumber = interaction, Priority = VMQueuePriority.UserDriven } ); }
public void RemoveRoomPortal(VMEntity obj) { var room = GetObjectRoom(obj); VMRoomPortal target = null; foreach (var port in RoomInfo[room].Portals) { if (port.ObjectID == obj.ObjectID) { target = port; break; } } if (target != null) RoomInfo[room].Portals.Remove(target); }
public void RegisterObjectPos(VMEntity obj) { var pos = obj.Position; if (pos.Level < 1) return; while (pos.Level > ObjectsAt.Count) ObjectsAt.Add(new Dictionary<int, List<short>>()); if (!ObjectsAt[pos.Level-1].ContainsKey(pos.TileID)) ObjectsAt[pos.Level - 1][pos.TileID] = new List<short>(); ObjectsAt[pos.Level - 1][pos.TileID].Add(obj.ObjectID); }
public ushort GetObjectRoom(VMEntity obj) { if (obj.Position == LotTilePos.OUT_OF_WORLD) return 0; if (obj.Position.Level < 1 || obj.Position.Level > _Arch.Stories) return 0; return Architecture.Rooms[obj.Position.Level - 1].Map[obj.Position.TileX + obj.Position.TileY*_Arch.Width]; }
public override void PlaceInSlot(VMEntity obj, int slot) { HandObject = obj; obj.Container = this; obj.ContainerSlot = (short)slot; obj.WorldUI.Container = this.WorldUI; obj.WorldUI.ContainerSlot = slot; obj.Position = Position; //TODO: is physical position the same as the slot offset position? if (obj.WorldUI is ObjectComponent) { var objC = (ObjectComponent)obj.WorldUI; objC.ForceDynamic = true; } }
/// <summary> /// Creates a new UILotControl instance. /// </summary> /// <param name="vm">A SimAntics VM instance.</param> /// <param name="World">A World instance.</param> public UILotControl(TSO.Simantics.VM vm, World World) { this.vm = vm; this.World = World; ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar); MouseEvt = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0, GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight), OnMouse); testimg = new UIImage(); testimg.X = 20; testimg.Y = 20; this.Add(testimg); Queue = new UIInteractionQueue(ActiveEntity); this.Add(Queue); ObjectHolder = new UIObjectHolder(vm, World, this); QueryPanel = new UIQueryPanel(World); QueryPanel.OnSellBackClicked += ObjectHolder.SellBack; QueryPanel.X = 177; QueryPanel.Y = GlobalSettings.Default.GraphicsHeight - 228; this.Add(QueryPanel); vm.OnDialog += vm_OnDialog; }
public void LiveModeUpdate(UpdateState state, bool scrolled) { //ActiveEntity = vm.Entities.Where(x => x is VMAvatar).ElementAt(0); //Queue.QueueOwner = ActiveEntity; if (ActiveEntity == null || ActiveEntity.Dead) { ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar); //try and hook onto a sim if we have none selected. Queue.QueueOwner = ActiveEntity; } if (MouseIsOn && ActiveEntity != null) { if (state.MouseState.X != OldMX || state.MouseState.Y != OldMY) { OldMX = state.MouseState.X; OldMY = state.MouseState.Y; var newHover = World.GetObjectIDAtScreenPos(state.MouseState.X, state.MouseState.Y, GameFacade.GraphicsDevice); //if (newHover == 0) newHover = ActiveEntity.ObjectID; if (ObjectHover != newHover) { ObjectHover = newHover; if (ObjectHover > 0) { var menu = vm.GetObjectById(ObjectHover).GetPieMenu(vm, ActiveEntity); InteractionsAvailable = (menu.Count > 0); } } } } else { ObjectHover = 0; } if (!scrolled) { //set cursor depending on interaction availability CursorType cursor; if (ObjectHover == 0) { cursor = CursorType.LiveNothing; } else { if (InteractionsAvailable) { if (vm.GetObjectById(ObjectHover) is VMAvatar) cursor = CursorType.LivePerson; else cursor = CursorType.LiveObjectAvail; } else { cursor = CursorType.LiveObjectUnavail; } } CursorManager.INSTANCE.SetCursor(cursor); } }
public override void ClearSlot(int slot) { HandObject.SetValue(VMStackObjectVariable.ContainerId, 0); HandObject.SetValue(VMStackObjectVariable.SlotNumber, 0); HandObject.WorldUI.Container = null; HandObject.WorldUI.ContainerSlot = 0; if (HandObject.WorldUI is ObjectComponent) { var objC = (ObjectComponent)HandObject.WorldUI; objC.ForceDynamic = false; } HandObject = null; }
public UIPieMenu(List<VMPieMenuInteraction> pie, VMEntity obj, VMEntity caller, UILotControl parent) { m_PieButtons = new List<UIButton>(); this.m_Obj = obj; this.m_Caller = caller; this.m_Parent = parent; this.ButtonStyle = new TextStyle { Font = GameFacade.MainFont, Size = 12, Color = new Color(0xA5, 0xC3, 0xD6), SelectedColor = new Color(0x00, 0xFF, 0xFF), CursorColor = new Color(255, 255, 255) }; m_Bg = new UIImage(TextureGenerator.GetPieBG(GameFacade.GraphicsDevice)); m_Bg.SetSize(0, 0); //is scaled up later this.AddAt(0, m_Bg); m_PieTree = new UIPieMenuItem() { Category = true }; for (int i = 0; i < pie.Count; i++) { string[] depth = pie[i].Name.Split('/'); var category = m_PieTree; //set category to root for (int j = 0; j < depth.Length-1; j++) //iterate through categories { if (category.Children.ContainsKey(depth[j])) { category = category.Children[depth[j]]; } else { var newCat = new UIPieMenuItem() { Category = true, Name = depth[j], Parent = category }; category.Children.Add(depth[j], newCat); category = newCat; } } //we are in the category, put the interaction in here; var item = new UIPieMenuItem() { Category = false, Name = depth[depth.Length-1], ID = pie[i].ID }; if (!category.Children.ContainsKey(item.Name)) category.Children.Add(item.Name, item); } m_CurrentItem = m_PieTree; m_PieButtons = new List<UIButton>(); RenderMenu(); VMAvatar Avatar = (VMAvatar)caller; m_Head = new SimAvatar(Avatar.Avatar); //talk about confusing... m_Head.StripAllButHead(); initSimHead(); }
// Begin Container SLOTs interface public abstract void PlaceInSlot(VMEntity obj,int slot);
public void ExecuteEntryPoint(int entry,VMContext context,bool runImmediately) { if (EntryPoints[entry].ActionFunction > 255) { BHAV bhav; GameIffResource CodeOwner; ushort ActionID = EntryPoints[entry].ActionFunction; if (ActionID < 4096) { //global bhav = context.Globals.Resource.Get <BHAV>(ActionID); CodeOwner = context.Globals.Resource; } else if (ActionID < 8192) { //local bhav = Object.Resource.Get <BHAV>(ActionID); CodeOwner = Object.Resource; } else { //semi-global bhav = SemiGlobal.Resource.Get <BHAV>(ActionID); CodeOwner = SemiGlobal.Resource; } var routine = context.VM.Assemble(bhav); if (bhav == null) { return; //throw new Exception("Invalid BHAV call!"); } short[] Args = null; VMEntity StackOBJ = null; if (entry == 1) { if (MainParam != 0) { Args = new short[4]; Args[0] = MainParam; MainParam = 0; } if (MainStackOBJ != 0) { StackOBJ = context.VM.GetObjectById(MainStackOBJ); MainStackOBJ = 0; } } var action = new TSO.Simantics.engine.VMQueuedAction { Callee = this, CodeOwner = CodeOwner, /** Main function **/ StackObject = StackOBJ, Routine = routine, Args = Args }; if (runImmediately) { VMThread.EvaluateCheck(context,this,action); } else { this.Thread.EnqueueAction(action); } } }
public void SetInfo(VMEntity entity, bool bought) { var obj = entity.Object; var def = entity.MasterDefinition; if (def == null) def = entity.Object.OBJ; CTSS catString = obj.Resource.Get<CTSS>(def.CatalogStringsID); if (catString != null) { DescriptionText.CurrentText = catString.GetString(0) + "\r\n" + catString.GetString(1); ObjectNameText.Caption = catString.GetString(0); } else { DescriptionText.CurrentText = entity.ToString(); ObjectNameText.Caption = entity.ToString(); } StringBuilder motivesString = new StringBuilder(); motivesString.AppendFormat(GameFacade.Strings.GetString("206", "19") + "${0}\r\n", def.Price); if (def.RatingHunger != 0) { motivesString.AppendFormat(AdStrings[0], def.RatingHunger); } if (def.RatingComfort != 0) { motivesString.AppendFormat(AdStrings[1], def.RatingComfort); } if (def.RatingHygiene != 0) { motivesString.AppendFormat(AdStrings[2], def.RatingHygiene); } if (def.RatingBladder != 0) { motivesString.AppendFormat(AdStrings[3], def.RatingBladder); } if (def.RatingEnergy != 0) { motivesString.AppendFormat(AdStrings[4], def.RatingEnergy); } if (def.RatingFun != 0) { motivesString.AppendFormat(AdStrings[5], def.RatingFun); } if (def.RatingRoom != 0) { motivesString.AppendFormat(AdStrings[6], def.RatingRoom); } var sFlags = def.RatingSkillFlags; for (int i = 0; i < 7; i++) { if ((sFlags & (1 << i)) > 0) motivesString.Append(AdStrings[i+7]); } MotivesText.CurrentText = motivesString.ToString(); ObjectOwnerText.Caption = GameFacade.Strings.GetString("206", "24", new string[] { "You" }); SpecificTabButton.Disabled = !bought; if (entity is VMGameObject) { var objects = entity.MultitileGroup.Objects; ObjectComponent[] objComps = new ObjectComponent[objects.Count]; for (int i=0; i<objects.Count; i++) { objComps[i] = (ObjectComponent)objects[i].WorldUI; } var thumb = World.GetObjectThumb(objComps, entity.MultitileGroup.GetBasePositions(), GameFacade.GraphicsDevice); if (Thumbnail.Texture != null) Thumbnail.Texture.Dispose(); Thumbnail.Texture = thumb; UpdateImagePosition(); } else { if (Thumbnail.Texture != null) Thumbnail.Texture.Dispose(); Thumbnail.Texture = null; } }
/// <summary> /// Removes an entity from this Virtual Machine. /// </summary> /// <param name="entity">The entity to remove.</param> public void RemoveEntity(VMEntity entity) { if (Entities.Contains(entity)) { this.Entities.Remove(entity); ObjectsById.Remove(entity.ObjectID); } entity.Dead = true; }
public override void Update(TSO.Common.rendering.framework.model.UpdateState state) { base.Update(state); if (ActiveEntity == null || ActiveEntity.Dead) { ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar); //try and hook onto a sim if we have none selected. Queue.QueueOwner = ActiveEntity; } if (Visible) { if (ShowTooltip) GameFacade.Screens.TooltipProperties.UpdateDead = false; var scrolled = World.TestScroll(state); if (MouseIsOn && ActiveEntity != null) { if (state.MouseState.X != OldMX || state.MouseState.Y != OldMY) { OldMX = state.MouseState.X; OldMY = state.MouseState.Y; var newHover = World.GetObjectIDAtScreenPos(state.MouseState.X, state.MouseState.Y, GameFacade.GraphicsDevice); if (newHover == 0) newHover = ActiveEntity.ObjectID; if (ObjectHover != newHover) { ObjectHover = newHover; if (ObjectHover > 0) { var menu = vm.GetObjectById(ObjectHover).GetPieMenu(vm, ActiveEntity); InteractionsAvailable = (menu.Count > 0); } } } } else { ObjectHover = 0; } if (!scrolled) { //set cursor depending on interaction availability CursorType cursor; if (ObjectHover == 0) { cursor = CursorType.LiveNothing; } else { if (InteractionsAvailable) { if (vm.GetObjectById(ObjectHover) is VMAvatar) cursor = CursorType.LivePerson; else cursor = CursorType.LiveObjectAvail; } else { cursor = CursorType.LiveObjectUnavail; } } CursorManager.INSTANCE.SetCursor(cursor); } //set cutaway around mouse var cuts = vm.Context.Blueprint.Cutaway; Rectangle newCut; if (WallsMode == 0){ newCut = new Rectangle(-1, -1, 1024, 1024); //cut all; walls down. } else if (WallsMode == 1) { var mouseTilePos = World.State.WorldSpace.GetTileAtPosWithScroll(new Vector2(state.MouseState.X, state.MouseState.Y + 128)); newCut = new Rectangle((int)(mouseTilePos.X - 1.5), (int)(mouseTilePos.Y - 1.5), 4, 4); } else { newCut = new Rectangle(0, 0, 0, 0); //walls up or roof } if (!newCut.Equals(MouseCutRect)) { if (cuts.Contains(MouseCutRect)) cuts.Remove(MouseCutRect); MouseCutRect = newCut; cuts.Add(MouseCutRect); vm.Context.Blueprint.Damage.Add(new tso.world.model.BlueprintDamage(tso.world.model.BlueprintDamageType.WALL_CUT_CHANGED)); } } }
/// <summary> /// Adds an entity to this Virtual Machine. /// </summary> /// <param name="entity">The entity to add.</param> public void AddEntity(VMEntity entity) { entity.ObjectID = ObjectId; ObjectsById.Add(entity.ObjectID, entity); AddToObjList(this.Entities, entity); ObjectId = NextObjID(); }
public void UnregisterObjectPos(VMEntity obj) { var pos = new VMTilePos(obj.WorldUI.TileX, obj.WorldUI.TileY, obj.WorldUI.Level); ObjectsAt[pos].Remove(obj.ObjectID); }
public override void PlaceInSlot(VMEntity obj, int slot) { HandObject = obj; obj.SetValue(VMStackObjectVariable.ContainerId, this.ObjectID); obj.SetValue(VMStackObjectVariable.SlotNumber, (short)slot); obj.WorldUI.Container = this.WorldUI; obj.WorldUI.ContainerSlot = slot; if (obj.WorldUI is ObjectComponent) { var objC = (ObjectComponent)obj.WorldUI; objC.ForceDynamic = true; } }
public ushort GetObjectRoom(VMEntity obj) { return(Blueprint.Rooms.Map[(int)(obj.Position.X + 0.5) + (int)(obj.Position.Y + 0.5) * Blueprint.Width]); }
public override void Update(UpdateState state) { base.Update(state); if (state.KeyboardState.IsKeyDown(Keys.Tab)) { if (!TabLastPressed) { //switch active sim ActiveEntity = vm.Entities.FirstOrDefault(x => (x is VMAvatar && x.ObjectID > ActiveEntity.ObjectID && x.Object.OBJ.GUID == 0x7FD96B54)); if (ActiveEntity == null) ActiveEntity = vm.Entities.FirstOrDefault(x => (x is VMAvatar && x.Object.OBJ.GUID == 0x7FD96B54)); HITVM.Get().PlaySoundEvent(UISounds.Speed1To3); Queue.QueueOwner = ActiveEntity; TabLastPressed = true; } } else TabLastPressed = false; if (Visible) { if (ShowTooltip) GameFacade.Screens.TooltipProperties.UpdateDead = false; bool scrolled = false; if (RMBScroll) { Vector2 scrollBy = new Vector2(); if (state.TouchMode) { scrollBy = new Vector2(RMBScrollX - state.MouseState.X, RMBScrollY - state.MouseState.Y); RMBScrollX = state.MouseState.X; RMBScrollY = state.MouseState.Y; scrollBy /= 128f; } else { scrollBy = new Vector2(state.MouseState.X - RMBScrollX, state.MouseState.Y - RMBScrollY); scrollBy *= 0.0005f; } World.Scroll(scrollBy); scrolled = true; } if (MouseIsOn) { if (state.MouseState.RightButton == ButtonState.Pressed) { if (RMBScroll == false) { RMBScroll = true; RMBScrollX = state.MouseState.X; RMBScrollY = state.MouseState.Y; } } else { RMBScroll = false; if (!scrolled && GlobalSettings.Default.EdgeScroll && !state.TouchMode) scrolled = World.TestScroll(state); } } if (LiveMode) LiveModeUpdate(state, scrolled); else if (CustomControl != null) CustomControl.Update(state, scrolled); else ObjectHolder.Update(state, scrolled); //set cutaway around mouse var cuts = vm.Context.Blueprint.Cutaway; Rectangle newCut; if (WallsMode == 0){ newCut = new Rectangle(-1, -1, 1024, 1024); //cut all; walls down. } else if (WallsMode == 1) { var mouseTilePos = World.State.WorldSpace.GetTileAtPosWithScroll(new Vector2(state.MouseState.X, state.MouseState.Y + 128)); newCut = new Rectangle((int)(mouseTilePos.X - 5.5), (int)(mouseTilePos.Y - 5.5), 11, 11); } else { newCut = new Rectangle(0, 0, 0, 0); //walls up or roof } if (!newCut.Equals(MouseCutRect)) { if (cuts.Contains(MouseCutRect)) cuts.Remove(MouseCutRect); MouseCutRect = newCut; cuts.Add(MouseCutRect); vm.Context.Blueprint.Damage.Add(new tso.world.model.BlueprintDamage(tso.world.model.BlueprintDamageType.WALL_CUT_CHANGED)); } } }
// End Container SLOTs interface public List<VMPieMenuInteraction> GetPieMenu(VM vm, VMEntity caller) { var pie = new List<VMPieMenuInteraction>(); if (TreeTable == null) return pie; for (int i = 0; i < TreeTable.Interactions.Length; i++) { var action = TreeTable.Interactions[i]; bool CanRun = false; if (action.TestFunction != 0 && (((TTABFlags)action.Flags & TTABFlags.Debug) != TTABFlags.Debug)) { caller.ObjectData[(int)VMStackObjectVariable.HideInteraction] = 0; var Behavior = GetBHAVWithOwner(action.TestFunction, vm.Context); CanRun = (VMThread.EvaluateCheck(vm.Context, caller, new VMQueuedAction() { Callee = this, CodeOwner = Behavior.owner, StackObject = this, Routine = vm.Assemble(Behavior.bhav), }) == VMPrimitiveExitCode.RETURN_TRUE); if (caller.ObjectData[(int)VMStackObjectVariable.HideInteraction] == 1) CanRun = false; } else { CanRun = true; } if (CanRun) pie.Add(new VMPieMenuInteraction() { Name = TreeTableStrings.GetString((int)action.TTAIndex), ID = (byte)action.TTAIndex }); } return pie; }
public override void ClearSlot(int slot) { HandObject.Container = null; HandObject.ContainerSlot = -1; HandObject.WorldUI.Container = null; HandObject.WorldUI.ContainerSlot = 0; if (HandObject.WorldUI is ObjectComponent) { var objC = (ObjectComponent)HandObject.WorldUI; objC.ForceDynamic = false; } HandObject = null; }
public abstract void PlaceInSlot(VMEntity obj, int slot);
public void AddRoomPortal(VMEntity obj) { var room = GetObjectRoom(obj); //find other portal part, must be in other room to count... foreach (var obj2 in obj.MultitileGroup.Objects) { var room2 = GetObjectRoom(obj2); if (obj != obj2 && room2 != room && obj2.EntryPoints[15].ActionFunction != 0) { RoomInfo[room].Portals.Add(new VMRoomPortal(obj.ObjectID, room2)); break; } } }
public void PushUserInteraction(int interaction, VMEntity caller, VMContext context) { var Action = TreeTable.InteractionByIndex[(uint)interaction]; ushort ActionID = Action.ActionFunction; var function = GetBHAVWithOwner(ActionID, context); VMEntity carriedObj = caller.GetSlot(0); var routine = context.VM.Assemble(function.bhav); caller.Thread.EnqueueAction( new TSO.Simantics.engine.VMQueuedAction { Callee = this, CodeOwner = function.owner, Routine = routine, Name = TreeTableStrings.GetString((int)Action.TTAIndex), StackObject = this, Args = ((Action.MaskFlags & InteractionMaskFlags.AvailableWhenCarrying) > 0) ? new short[] { (carriedObj == null)?(short)0:carriedObj.ObjectID, 0, 0, 0 }:null, InteractionNumber = interaction, Priority = VMQueuePriority.UserDriven } ); }
public VMPlacementResult GetObjPlace(VMEntity target, LotTilePos pos) { //ok, this might be confusing... short allowedHeights = target.GetValue(VMStackObjectVariable.AllowedHeightFlags); short weight = target.GetValue(VMStackObjectVariable.Weight); var tflags = (VMEntityFlags)target.GetValue(VMStackObjectVariable.Flags); bool noFloor = (allowedHeights&1)==0; VMPlacementError status = (noFloor)?VMPlacementError.HeightNotAllowed:VMPlacementError.Success; if ((tflags & VMEntityFlags.HasZeroExtent) > 0 || pos.Level < 1 || pos.Level > ObjectsAt.Count || (!ObjectsAt[pos.Level - 1].ContainsKey(pos.TileID))) { return new VMPlacementResult { Status = status }; } var objs = ObjectsAt[pos.Level - 1][pos.TileID]; foreach (var id in objs) { var obj = VM.GetObjectById(id); if (obj == null || obj.MultitileGroup == target.MultitileGroup) continue; var flags = (VMEntityFlags)obj.GetValue(VMStackObjectVariable.Flags); if ((flags & VMEntityFlags.HasZeroExtent) == 0) { status = VMPlacementError.CantIntersectOtherObjects; //this object is technically solid. Check if we can place on top of it if (allowedHeights>1 && obj.TotalSlots() > 0 && (obj.GetSlot(0) == null || obj.GetSlot(0) == target)) { //first check if we have a slot 0, which is what we place onto. then check if it's empty, //then check if the object can support this one's weight. //we also need to make sure that the height of this specific slot is allowed. if (((1 << (obj.GetSlotHeight(0) - 1)) & allowedHeights) > 0) { if (weight < obj.GetValue(VMStackObjectVariable.SupportStrength)) { return new VMPlacementResult { Status = VMPlacementError.Success, Container = obj }; } else { status = VMPlacementError.CantSupportWeight; } } else { if (noFloor) { if ((allowedHeights & (1 << 3)) > 0) status = VMPlacementError.CounterHeight; else status = (obj.GetSlotHeight(0) == 8) ? VMPlacementError.CannotPlaceComputerOnEndTable : VMPlacementError.HeightNotAllowed; } } } } } return new VMPlacementResult { Status = status }; }
public override void PlaceInSlot(VMEntity obj, int slot) { if (SlotContainees != null) { if (slot > -1 && slot < SlotContainees.Length) { SlotContainees[slot] = obj; //if (obj is VMAvatar) obj.Direction = this.Direction; obj.SetValue(VMStackObjectVariable.ContainerId, this.ObjectID); obj.SetValue(VMStackObjectVariable.SlotNumber, (short)slot); obj.WorldUI.Container = this.WorldUI; obj.WorldUI.ContainerSlot = slot; } } }
public void RemoveObjectInstance(VMEntity target) { target.PrePositionChange(this); VM.RemoveEntity(target); if (target is VMGameObject) Blueprint.RemoveObject((ObjectComponent)target.WorldUI); else Blueprint.RemoveAvatar((AvatarComponent)target.WorldUI); }
/// <summary> /// Removes an entity from this Virtual Machine. /// </summary> /// <param name="entity">The entity to remove.</param> public void RemoveEntity(VMEntity entity) { if (Entities.Contains(entity)) { this.Entities.Remove(entity); ObjectsById.Remove(entity.ObjectID); if (entity.ObjectID < ObjectId) ObjectId = entity.ObjectID; //this id is now the smallest free object id. } entity.Dead = true; }
public void UnregisterObjectPos(VMEntity obj) { var pos = obj.Position; if (ObjectsAt[pos.Level - 1].ContainsKey(pos.TileID)) ObjectsAt[pos.Level - 1][pos.TileID].Remove(obj.ObjectID); }
public void SetSelected(VMMultitileGroup Group) { if (Holding != null) ClearSelected(); Holding = new UIObjectSelection(); Holding.Group = Group; Holding.PreviousTile = Holding.Group.BaseObject.Position; Holding.Dir = Group.Objects[0].Direction; VMEntity[] CursorTiles = new VMEntity[Group.Objects.Count]; for (int i = 0; i < Group.Objects.Count; i++) { var target = Group.Objects[i]; if (target is VMGameObject) ((ObjectComponent)target.WorldUI).ForceDynamic = true; CursorTiles[i] = vm.Context.CreateObjectInstance(0x00000437, new LotTilePos(target.Position), tso.world.model.Direction.NORTH).Objects[0]; CursorTiles[i].SetPosition(new LotTilePos(0,0,1), Direction.NORTH, vm.Context); ((ObjectComponent)CursorTiles[i].WorldUI).ForceDynamic = true; } Holding.TilePosOffset = new Vector2(0, 0); Holding.CursorTiles = CursorTiles; }