public VMModifyDataCommand(VMExtDataType type, int id, int value, VMEntity obj)
 {
     Type = type;
     ID = id;
     Value = value;
     Object = obj;
 }
Exemple #2
0
        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));
            }
        }
Exemple #3
0
        public Simantics(VM vm)
        {
            this.vm = vm;
            InitializeComponent();

            ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar);

            aq = new ActionQueue();
            aq.Show();
            aq.target = ActiveEntity;
        }
        private int UseLastValue; //times to use last believed value before we poll the real entity.

        #endregion Fields

        #region Constructors

        public VMDataPropertyDescriptor(string name, string description, Attribute[] attrs, VMExtDataType type, int id, 
            VMEntity obj, VMStackFrame frame, UIBHAVEditor editor)
            : base(name, attrs)
        {
            Type = type;
            ID = id;
            Object = obj;
            Frame = frame;
            Editor = editor;
            _Description = description;
        }
Exemple #5
0
 public void IDEBreakpointHit(VM vm, VMEntity targetEnt)
 {
     new Thread(() =>
     {
         if (MainWindow.Instance == null) return;
         MainWindow.Instance.Invoke(new MainWindowDelegate(() =>
         {
             MainWindow.Instance.BHAVManager.OpenTracer(vm, targetEnt);
         }), null);
     }).Start();
 }
Exemple #6
0
        private VMEntity DeepestObjInSlot(VMEntity pt, int depth)
        {
            //todo: make sure nobody can create cyclic slots, and limit slot depth
            if (depth > 50)
            {
                throw new Exception("slot depth too high!");
            }
            var slots = pt.TotalSlots();

            for (int i = 0; i < slots; i++)
            {
                var ent = pt.GetSlot(i);
                if (ent != null)
                {
                    return(DeepestObjInSlot(ent, depth++));
                }
            }
            return(pt);
        }
Exemple #7
0
 public void RemoveObjectInstance(VMEntity target)
 {
     target.PrePositionChange(this);
     if (!target.GhostImage)
     {
         VM.RemoveEntity(target);
     }
     if (UseWorld)
     {
         if (target is VMGameObject)
         {
             Blueprint.RemoveObject((ObjectComponent)target.WorldUI);
         }
         else
         {
             Blueprint.RemoveAvatar((AvatarComponent)target.WorldUI);
         }
     }
 }
Exemple #8
0
        public BHAVEditor OpenTracer(VM vm, VMEntity entity)
        {
            BHAVEditor window;
            if (Tracers.ContainsKey(entity))
            {
                window = Tracers[entity];
                window.UpdateDebugger();
                var form = (Form)window;
                if (form.WindowState == FormWindowState.Minimized) form.WindowState = FormWindowState.Normal;
                window.Activate();
                return window;
            }

            window = new BHAVEditor(vm, entity);
            window.Show();
            window.Activate();
            Tracers.Add(entity, window);
            return window;
        }
Exemple #9
0
        public void InitBHAV(BHAV bhav, EditorScope scope, VMEntity debugEnt, VMStackFrame debugFrame, BHAVPrimSelect callback)
        {
            if (FSOUI == null)
            {
                var mainCont = new UIExternalContainer(1024, 768);
                Editor = new UIBHAVEditor(bhav, scope, debugEnt);
                mainCont.Add(Editor);
                GameFacade.Screens.AddExternal(mainCont);

                SetUI(mainCont);
                Editor.BHAVView.OnSelectedChanged += callback;
            } else
            {
                //reuse existing
                lock (FSOUI)
                {
                    Editor.QueueCommand(new ChangeBHAVCommand(bhav, scope, debugFrame, callback));
                }
            }
        }
Exemple #10
0
        public void UnregisterObjectPos(VMEntity obj)
        {
            var pos = obj.Position;

            //remove object from room

            var room = GetObjectRoom(obj);

            RoomInfo[room].Entities.Remove(obj);
            if (obj.EntryPoints[15].ActionFunction != 0)
            { //portal
                RemoveRoomPortal(obj, room);
            }
            if (obj.GetValue(VMStackObjectVariable.LightingContribution) > 0)
            {
                RefreshLighting(room, true);
            }

            SetToNextCache.UnregisterObjectPos(obj);
        }
        public override void ClearSlot(int slot)
        {
            HandObject.Container     = null;
            HandObject.ContainerSlot = -1;
            CarryAnimationState      = null;

            if (UseWorld)
            {
                HandObject.WorldUI.Container     = null;
                HandObject.WorldUI.ContainerSlot = 0;

                if (HandObject.WorldUI is ObjectComponent)
                {
                    var objC = (ObjectComponent)HandObject.WorldUI;
                    objC.ForceDynamic = false;
                }
            }

            HandObject = null;
        }
        public override bool PlaceInSlot(VMEntity obj, int slot, bool cleanOld, VMContext context)
        {
            if (GetSlot(slot) == obj)
            {
                return(true);                      //already in slot
            }
            if (GetSlot(slot) != null)
            {
                return(false);
            }
            if (cleanOld)
            {
                obj.PrePositionChange(context);
            }

            if (!obj.GhostImage)
            {
                HandObject = obj;

                CarryAnimationState = new VMAnimationState(FSO.Content.Content.Get().AvatarAnimations.Get("a2o-rarm-carry-loop.anim"), false); //set default carry animation

                obj.Container     = this;
                obj.ContainerSlot = (short)slot;
            }
            if (UseWorld)
            {
                obj.WorldUI.Container     = this.WorldUI;
                obj.WorldUI.ContainerSlot = slot;
                if (obj.WorldUI is ObjectComponent)
                {
                    var objC = (ObjectComponent)obj.WorldUI;
                    objC.ForceDynamic = true;
                }
            }
            obj.Position = Position; //TODO: is physical position the same as the slot offset position?
            if (cleanOld)
            {
                obj.PositionChange(context, false);
            }
            return(true);
        }
Exemple #13
0
        public override bool PlaceInSlot(VMEntity obj, int slot, bool cleanOld, VMContext context)
        {
            if (GetSlot(slot) == obj)
            {
                return(true);                      //already in slot
            }
            if (GetSlot(slot) != null || WillLoopSlot(obj))
            {
                return(false);                                            //would recursively loop slot..
            }
            if (cleanOld)
            {
                obj.PrePositionChange(context);
            }

            if (Contained != null)
            {
                if (slot > -1 && slot < Contained.Length)
                {
                    if (!obj.GhostImage)
                    {
                        Contained[slot]   = obj;
                        obj.Container     = this;
                        obj.ContainerSlot = (short)slot;
                    }

                    if (UseWorld)
                    {
                        obj.WorldUI.Container     = this.WorldUI;
                        obj.WorldUI.ContainerSlot = slot;
                    }
                    obj.Position = Position; //TODO: is physical position the same as the slot offset position?
                    if (cleanOld)
                    {
                        obj.PositionChange(context, false);
                    }
                    return(true);
                }
            }
            return(false);
        }
        public virtual void LoadCrossRef(VMAvatarMarshal input, VMContext context)
        {
            base.LoadCrossRef(input, context);
            HandObject = context.VM.GetObjectById(input.HandObject);
            if (HandObject != null && HandObject is VMGameObject)
            {
                ((ObjectComponent)HandObject.WorldUI).ForceDynamic = true;
            }
            //we need to fix the gender, since InitBodyData resets it.
            var gender = GetPersonData(VMPersonDataVariable.Gender);

            InitBodyData(context);
            SetPersonData(VMPersonDataVariable.Gender, gender);
            SetPersonData(VMPersonDataVariable.RenderDisplayFlags, GetPersonData(VMPersonDataVariable.RenderDisplayFlags));
            BodyOutfit = input.BodyOutfit;
            HeadOutfit = input.HeadOutfit;

            Avatar.Head      = Content.Content.Get().AvatarOutfits.Get(HeadOutfit);
            Avatar.Body      = Content.Content.Get().AvatarOutfits.Get(BodyOutfit);
            Avatar.Handgroup = Avatar.Body;
        }
Exemple #15
0
        public void UnregisterObjectPos(VMEntity obj)
        {
            var pos = obj.Position;

            //remove object from room

            var room = GetObjectRoom(obj);

            RoomInfo[room].Entities.Remove(obj);
            if (obj.EntryPoints[15].ActionFunction != 0)
            { //portal
                RemoveRoomPortal(obj, room);
            }
            if (obj.GetValue(VMStackObjectVariable.LightingContribution) > 0)
            {
                RefreshLighting(room, true);
            }

            if (ObjectsAt[pos.Level - 1].ContainsKey(pos.TileID))
            {
                ObjectsAt[pos.Level - 1][pos.TileID].Remove(obj.ObjectID);
            }
        }
Exemple #16
0
        public virtual void LoadCrossRef(VMEntityMarshal input,VMContext context)
        {
            Contained = new VMEntity[input.Contained.Length];
            int i = 0;

            foreach (var item in input.Contained)
            {
                Contained[i++] = context.VM.GetObjectById(item);
            }

            Container = context.VM.GetObjectById(input.Container);
            if (UseWorld && Container != null)
            {
                WorldUI.Container     = Container.WorldUI;
                WorldUI.ContainerSlot = ContainerSlot;
            }

            if (input.Headline != null)
            {
                Headline         = new VMRuntimeHeadline(input.Headline,context);
                HeadlineRenderer = context.VM.Headline.Get(Headline);
            }
        }
Exemple #17
0
        public virtual void Init(VMContext context)
        {
            GenerateTreeByName(context);
            if (!GhostImage)
            {
                this.Thread = new VMThread(context,this,this.Object.OBJ.StackSize);
            }

            ExecuteEntryPoint(0,context,true);   //Init

            if (!GhostImage)
            {
                short[]  Args     = null;
                VMEntity StackOBJ = null;
                if (MainParam != 0)
                {
                    Args      = new short[4];
                    Args[0]   = MainParam;
                    MainParam = 0;
                }
                if (MainStackOBJ != 0)
                {
                    StackOBJ     = context.VM.GetObjectById(MainStackOBJ);
                    MainStackOBJ = 0;
                }

                ExecuteEntryPoint(1,context,false,StackOBJ,Args);     //Main
            }
            else
            {
                SetValue(VMStackObjectVariable.Room,-1);
                if (this is VMGameObject)
                {
                    ((VMGameObject)this).RefreshLight();
                }
            }
        }
Exemple #18
0
        public void UnregisterObjectPos(VMEntity obj)
        {
            var pos = obj.Position;

            //remove object from room

            var room = GetObjectRoom(obj);
            RoomInfo[room].Entities.Remove(obj);
            if (obj.EntryPoints[15].ActionFunction != 0)
            { //portal
                RemoveRoomPortal(obj, room);
            }

            if (ObjectsAt[pos.Level - 1].ContainsKey(pos.TileID)) ObjectsAt[pos.Level - 1][pos.TileID].Remove(obj.ObjectID);
        }
Exemple #19
0
 private void SetBreak(VMEntity entity)
 {
     entity.Thread.ThreadBreak = SimAntics.Engine.VMThreadBreakMode.Immediate;
 }
Exemple #20
0
        public bool ExecuteEntryPoint(int entry,VMContext context,bool runImmediately,VMEntity stackOBJ,short[] args)
        {
            if (entry == 11)
            {
                //user placement, hack to do auto floor removal/placement for stairs
                if (Object.OBJ.LevelOffset > 0 && Position != LotTilePos.OUT_OF_WORLD)
                {
                    var floor      = context.Architecture.GetFloor(Position.TileX,Position.TileY,Position.Level);
                    var placeFlags = (VMPlacementFlags)ObjectData[(int)VMStackObjectVariable.PlacementFlags];
                    if ((placeFlags & VMPlacementFlags.InAir) > 0)
                    {
                        context.Architecture.SetFloor(Position.TileX,Position.TileY,Position.Level,new FloorTile(),true);
                    }
                    if ((placeFlags & VMPlacementFlags.OnFloor) > 0 && (floor.Pattern == 0))
                    {
                        context.Architecture.SetFloor(Position.TileX,Position.TileY,Position.Level,new FloorTile {
                            Pattern = 1
                        },true);
                    }
                }
            }

            bool result = false;

            if (EntryPoints[entry].ActionFunction > 255)
            {
                VMSandboxRestoreState SandboxState = null;
                if (GhostImage && runImmediately)
                {
                    SandboxState = context.VM.Sandbox();
                    for (int i = 0; i < MultitileGroup.Objects.Count; i++)
                    {
                        var obj = MultitileGroup.Objects[i];
                        context.VM.AddEntity(obj);
                    }
                }

                BHAV       bhav;
                GameObject CodeOwner;
                ushort     ActionID = EntryPoints[entry].ActionFunction;
                if (ActionID < 4096)
                { //global
                    bhav = context.Globals.Resource.Get <BHAV>(ActionID);
                }
                else if (ActionID < 8192)
                { //local
                    bhav = Object.Resource.Get <BHAV>(ActionID);
                }
                else
                { //semi-global
                    bhav = SemiGlobal.Get <BHAV>(ActionID);
                }

                CodeOwner = Object;

                if (bhav != null)
                {
                    var routine = context.VM.Assemble(bhav);
                    var action  = new VMQueuedAction
                    {
                        Callee    = this,
                        CodeOwner = CodeOwner,
                        /** Main function **/
                        StackObject = stackOBJ,
                        Routine     = routine,
                        Args        = args
                    };

                    if (runImmediately)
                    {
                        var checkResult = VMThread.EvaluateCheck(context,this,action);
                        result = (checkResult == VMPrimitiveExitCode.RETURN_TRUE);
                    }
                    else
                    {
                        this.Thread.EnqueueAction(action);
                    }
                }

                if (GhostImage && runImmediately)
                {
                    //restore state
                    context.VM.SandboxRestore(SandboxState);
                }
                return(result);
            }
            else
            {
                return(false);
            }
        }
Exemple #21
0
 public void RemoveRoomPortal(VMEntity obj, ushort room)
 {
     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);
 }
Exemple #22
0
 public abstract void PlaceInSlot(VMEntity obj,int slot,bool cleanOld,VMContext context);
Exemple #23
0
 public virtual void LoadCrossRef(VMAvatarMarshal input, VMContext context)
 {
     base.LoadCrossRef(input, context);
     HandObject = context.VM.GetObjectById(input.HandObject);
     if (HandObject != null && HandObject is VMGameObject) ((ObjectComponent)HandObject.WorldUI).ForceDynamic = true;
     //we need to fix the gender, since InitBodyData resets it.
     var gender = GetPersonData(VMPersonDataVariable.Gender);
     InitBodyData(context);
     SetPersonData(VMPersonDataVariable.Gender, gender);
     BodyOutfit = input.BodyOutfit;
     HeadOutfit = input.HeadOutfit;
 }
Exemple #24
0
 private void btnSelect_Click(object sender, EventArgs e)
 {
     ActiveEntity = SelectedEntity;
     aq.target = ActiveEntity;
 }
Exemple #25
0
        public override void Init(FSO.SimAntics.VMContext context)
        {
            if (UseWorld) ((ObjectComponent)WorldUI).ObjectID = ObjectID;
            if (Slots != null && Slots.Slots.ContainsKey(0))
            {
                Contained = new VMEntity[Slots.Slots[0].Count];
                if (UseWorld) ((ObjectComponent)WorldUI).ContainerSlots = Slots.Slots[0];
            }

            base.Init(context);
        }
Exemple #26
0
 public void AddRoomPortal(VMEntity obj, ushort room)
 {
     //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;
         }
     }
 }
Exemple #27
0
        public VMPlacementResult GetObjPlace(VMEntity target, LotTilePos pos, Direction dir)
        {
            //ok, this might be confusing...
            short allowedHeights = target.GetValue(VMStackObjectVariable.AllowedHeightFlags);
            short weight         = target.GetValue(VMStackObjectVariable.Weight);
            bool  noFloor        = (allowedHeights & 1) == 0;

            var  flags        = (VMEntityFlags)target.GetValue(VMStackObjectVariable.Flags);
            bool allowAvatars = ((flags & VMEntityFlags.DisallowPersonIntersection) == 0) && ((flags & VMEntityFlags.AllowPersonIntersection) > 0);

            VMObstacle footprint = target.GetObstacle(pos, dir);
            ushort     room      = GetRoomAt(pos);

            VMPlacementError status    = (noFloor)?VMPlacementError.HeightNotAllowed:VMPlacementError.Success;
            VMEntity         statusObj = null;

            if (footprint == null || pos.Level < 1)
            {
                return(new VMPlacementResult {
                    Status = status
                });
            }

            var objs = RoomInfo[room].Entities;

            foreach (var obj in objs)
            {
                if (obj.MultitileGroup == target.MultitileGroup || (obj is VMAvatar && allowAvatars) ||
                    (target.GhostImage && target.GhostOriginal != null && target.GhostOriginal.Objects.Contains(obj)))
                {
                    continue;
                }
                var oFoot = obj.Footprint;

                if (oFoot != null && oFoot.Intersects(footprint) &&
                    (!(target.ExecuteEntryPoint(5, this, true, obj, new short[] { obj.ObjectID, 0, 0, 0 }) ||
                       obj.ExecuteEntryPoint(5, this, true, target, new short[] { target.ObjectID, 0, 0, 0 })))
                    )
                {
                    statusObj = obj;
                    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(VMPlacementError.Success, 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, statusObj));
        }
Exemple #28
0
        public VMPlacementError Status; //if true, cannot place anywhere.

        #endregion Fields

        #region Constructors

        public VMPlacementResult(VMPlacementError status)
        {
            Status = status;
            Object = null;
        }
        public void SetGUIDLocal(uint id, VM TempVM)
        {
            oldGUID = id;
            GUID = id;
            if (TempVM != null)
            {
                if (TargetOBJ != null) TargetOBJ.Delete(TempVM.Context);
                //create our master, center camera on target object
                var objDefinition = FSO.Content.Content.Get().WorldObjects.Get(GUID);

                if (objDefinition != null)
                {
                    var masterID = id;
                    var notMaster = objDefinition.OBJ.MasterID != 0 && objDefinition.OBJ.SubIndex != -1;
                    if (notMaster)
                    {
                        //find the master
                        var master = objDefinition.Resource.List<OBJD>().FirstOrDefault(x => x.MasterID == objDefinition.OBJ.MasterID && x.SubIndex == -1);
                        if (master != null) masterID = master.GUID;
                    }
                    TargetOBJ = TempVM.Context.CreateObjectInstance(masterID, LotTilePos.OUT_OF_WORLD, Direction.SOUTH, true);
                    TargetOBJ.SetVisualPosition(new Vector3(0.5f, 0.5f, 0f), Direction.SOUTH, TempVM.Context);
                    TempVM.Entities = TargetOBJ.Objects;
                    if (TargetOBJ == null) return;
                    TargetTile = TargetOBJ.Objects.FirstOrDefault(x => x.Object.OBJ.GUID == id);
                    if (TargetTile == null) TargetTile = TargetOBJ.BaseObject;
                    var tile = TargetTile.VisualPosition;
                    TempVM.Context.World.State.CenterTile = new Vector2(tile.X, tile.Y) - new Vector2(2.5f, 2.5f);
                    foreach (var obj in TargetOBJ.Objects)
                    {
                        if (obj is VMGameObject) ((ObjectComponent)obj.WorldUI).renderInfo.Layer = LotView.WorldObjectRenderLayer.DYNAMIC;
                        if (notMaster && obj.Object.OBJ.GUID != id) obj.SetRoom(2);
                    }
                }
            }
        }
Exemple #30
0
        public override void PlaceInSlot(VMEntity obj, int slot, bool cleanOld, VMContext context)
        {
            if (cleanOld) obj.PrePositionChange(context);

            if (Contained != null)
            {
                if (slot > -1 && slot < Contained.Length)
                {
                    if (!obj.GhostImage)
                    {
                        Contained[slot] = obj;
                        obj.Container = this;
                        obj.ContainerSlot = (short)slot;
                    }

                    if (UseWorld)
                    {
                        obj.WorldUI.Container = this.WorldUI;
                        obj.WorldUI.ContainerSlot = slot;
                    }
                    obj.Position = Position; //TODO: is physical position the same as the slot offset position?
                }
            }
        }
Exemple #31
0
        private void SetSelected(VMEntity entity)
        {
            SelectedEntity = entity;
            propertyGrid.SelectedObject = entity;

            bhavList.Items.Clear();
            var resource = entity.Object;
            var bhavs = resource.Resource.List<BHAV>();
            if (bhavs != null)
            {
                foreach (var bhav in bhavs)
                {
                    bhavList.Items.Add(bhav);
                }
            }

            if (entity.SemiGlobal != null)
            {
                var sglobbhavs = entity.SemiGlobal.Resource.List<BHAV>();
                if (bhavs != null)
                {
                    foreach (var bhav in sglobbhavs)
                    {
                        bhavList.Items.Add(bhav);
                    }
                }
            }

            interactionList.Items.Clear();
            if (entity.TreeTable != null)
            {
                TreeTableSel = entity.TreeTable;
                foreach (var interaction in entity.TreeTable.Interactions)
                {
                    interactionList.Items.Add(entity.TreeTableStrings.GetString((int)interaction.TTAIndex));
                }
            }
        }
Exemple #32
0
 public void PushUserInteraction(int interaction,VMEntity caller,VMContext context)
 {
     PushUserInteraction(interaction,caller,context,null);
 }
Exemple #33
0
        public UIBHAVEditor(BHAV target, EditorScope scope, VMEntity debugEnt)
        {
            if (debugEnt != null)
            {
                DebugMode = true;
                DebugEntity = debugEnt;
            }

            ContainerByID = new Dictionary<ushort, BHAVContainer>();
            BHAVView = new BHAVContainer(target, scope);
            ContainerByID.Add(target.ChunkID, BHAVView);
            this.Add(BHAVView);

            PlacingName = new UILabel();
            PlacingName.Alignment = TextAlignment.Center;
            PlacingName.Size = new Vector2(1, 1);
            PlacingName.CaptionStyle = TextStyle.DefaultLabel.Clone();
            PlacingName.CaptionStyle.Font = FSO.Client.GameFacade.EdithFont;
            PlacingName.CaptionStyle.Size = 14;
            PlacingName.CaptionStyle.Color = new Color(0, 102, 26);

            PlacingName.Caption = "Placing Report Metric";

            PlacingDesc = new UILabel();
            PlacingDesc.Alignment = TextAlignment.Center;
            PlacingDesc.Size = new Vector2(1, 1);
            PlacingDesc.CaptionStyle = TextStyle.DefaultLabel.Clone();
            PlacingDesc.CaptionStyle.Font = FSO.Client.GameFacade.EdithFont;
            PlacingDesc.CaptionStyle.Size = 12;
            PlacingDesc.CaptionStyle.Color = new Color(0, 102, 26);

            PlacingDesc.Caption = "Press ESC to cancel.";

            this.Add(PlacingName);
            this.Add(PlacingDesc);

            if (DebugMode)
            {
                DebugFrame = debugEnt.Thread.Stack.LastOrDefault();
                UpdateDebugPointer(DebugFrame);
                DebugGo = new UIButton();
                DebugGo.Caption = "Go";
                DebugGo.Position = new Vector2(15, 15);
                Add(DebugGo);
                DebugGo.OnButtonClick += DebugButtonClick;

                DebugStepOver = new UIButton();
                DebugStepOver.Caption = "Step Over";
                DebugStepOver.Position = new Vector2(83, 15);
                Add(DebugStepOver);
                DebugStepOver.OnButtonClick += DebugButtonClick;

                DebugStepIn = new UIButton();
                DebugStepIn.Caption = "Step In";
                DebugStepIn.Position = new Vector2(193, 15);
                Add(DebugStepIn);
                DebugStepIn.OnButtonClick += DebugButtonClick;

                DebugStepOut = new UIButton();
                DebugStepOut.Caption = "Step Out";
                DebugStepOut.Position = new Vector2(293, 15);
                Add(DebugStepOut);
                DebugStepOut.OnButtonClick += DebugButtonClick;

                DebugTrue = new UIButton();
                DebugTrue.Caption = "Return True";
                DebugTrue.Position = new Vector2(402, 15);
                Add(DebugTrue);
                DebugTrue.OnButtonClick += DebugButtonClick;

                DebugFalse = new UIButton();
                DebugFalse.Caption = "Return False";
                DebugFalse.Position = new Vector2(522, 15);
                Add(DebugFalse);
                DebugFalse.OnButtonClick += DebugButtonClick;
            }
        }
Exemple #34
0
        public override void PlaceInSlot(VMEntity obj, int slot, bool cleanOld, VMContext context)
        {
            if (cleanOld) obj.PrePositionChange(context);

            if (!obj.GhostImage)
            {
                HandObject = obj;

                CarryAnimationState = new VMAnimationState(FSO.Content.Content.Get().AvatarAnimations.Get("a2o-rarm-carry-loop.anim"), false); //set default carry animation

                obj.Container = this;
                obj.ContainerSlot = (short)slot;
            }
            if (UseWorld)
            {
                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;
                }
            }
        }
Exemple #35
0
 internal void BreakpointHit(VMEntity entity)
 {
     if (OnBreakpoint == null) entity.Thread.ThreadBreak = VMThreadBreakMode.Active; //no handler..
     else OnBreakpoint(entity);
 }
Exemple #36
0
        public UIPieMenu(List<VMPieMenuInteraction> pie, VMEntity obj, VMEntity caller, UILotControl parent)
        {
            if (FSOEnvironment.UIZoomFactor>1.33f) ScaleX = ScaleY = FSOEnvironment.UIZoomFactor*0.75f;
            TrueScale = ScaleX *FSOEnvironment.DPIScaleFactor;
            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 == null)?new string[] { "???" } :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,
                    Param0 = pie[i].Param0
                };
                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();
        }
Exemple #37
0
        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];
                var actionStrings = new List <VMPieMenuInteraction>();

                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),
                    },actionStrings) == VMPrimitiveExitCode.RETURN_TRUE);
                    if (caller.ObjectData[(int)VMStackObjectVariable.HideInteraction] == 1)
                    {
                        CanRun = false;
                    }
                }
                else
                {
                    CanRun = true;
                }

                if (CanRun)
                {
                    if (actionStrings.Count > 0)
                    {
                        foreach (var actionS in actionStrings)
                        {
                            actionS.ID = (byte)action.TTAIndex;
                            pie.Add(actionS);
                        }
                    }
                    else
                    {
                        if (TreeTableStrings != null)
                        {
                            pie.Add(new VMPieMenuInteraction()
                            {
                                Name = TreeTableStrings.GetString((int)action.TTAIndex),
                                ID   = (byte)action.TTAIndex
                            });
                        }
                    }
                }
            }

            return(pie);
        }
Exemple #38
0
 public VMPlacementResult(VMPlacementError status, VMEntity obj)
 {
     Status = status;
     Object = obj;
 }
Exemple #39
0
 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];
 }
Exemple #40
0
        public override void ClearSlot(int slot)
        {
            HandObject.Container = null;
            HandObject.ContainerSlot = -1;
            CarryAnimationState = null;

            if (UseWorld)
            {
                HandObject.WorldUI.Container = null;
                HandObject.WorldUI.ContainerSlot = 0;

                if (HandObject.WorldUI is ObjectComponent)
                {
                    var objC = (ObjectComponent)HandObject.WorldUI;
                    objC.ForceDynamic = false;
                }
            }

            HandObject = null;
        }
Exemple #41
0
        public VMPlacementResult GetObjPlace(VMEntity target, LotTilePos pos, Direction dir)
        {
            //ok, this might be confusing...
            short allowedHeights = target.GetValue(VMStackObjectVariable.AllowedHeightFlags);
            short weight = target.GetValue(VMStackObjectVariable.Weight);
            bool noFloor = (allowedHeights&1)==0;

            var flags = (VMEntityFlags)target.GetValue(VMStackObjectVariable.Flags);
            bool allowAvatars = ((flags & VMEntityFlags.DisallowPersonIntersection) == 0) && ((flags & VMEntityFlags.AllowPersonIntersection) > 0);

            VMObstacle footprint = target.GetObstacle(pos, dir);
            ushort room = GetRoomAt(pos);

            VMPlacementError status = (noFloor)?VMPlacementError.HeightNotAllowed:VMPlacementError.Success;
            VMEntity statusObj = null;

            if (footprint == null || pos.Level < 1)
            {
                return new VMPlacementResult { Status = status };
            }

            var objs = RoomInfo[room].Entities;
            foreach (var obj in objs)
            {
                if (obj.MultitileGroup == target.MultitileGroup || (obj is VMAvatar && allowAvatars)) continue;
                var oFoot = obj.Footprint;

                if (oFoot != null && oFoot.Intersects(footprint)
                    && (!(target.ExecuteEntryPoint(5, this, true, obj, new short[] { obj.ObjectID, 0, 0, 0 })
                        || obj.ExecuteEntryPoint(5, this, true, target, new short[] { target.ObjectID, 0, 0, 0 })))
                    )
                {
                    statusObj = obj;
                    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(VMPlacementError.Success, 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, statusObj);
        }
Exemple #42
0
        public void RegisterObjectPos(VMEntity obj)
        {
            var pos = obj.Position;
            if (pos.Level < 1) return;

            //add object to room

            var room = GetObjectRoom(obj);
            VM.AddToObjList(RoomInfo[room].Entities, obj);
            if (obj.EntryPoints[15].ActionFunction != 0)
            { //portal
                AddRoomPortal(obj, room);
            }

            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);
        }
Exemple #43
0
        public VMEntity         Object; //Container if above is .Success, Obstacle if above is any failure code.

        public VMPlacementResult(VMPlacementError status)
        {
            Status = status;
            Object = null;
        }
Exemple #44
0
 public void RemoveObjectInstance(VMEntity target)
 {
     target.PrePositionChange(this);
     if (!target.GhostImage) VM.RemoveEntity(target);
     if (UseWorld)
     {
         if (target is VMGameObject) Blueprint.RemoveObject((ObjectComponent)target.WorldUI);
         else Blueprint.RemoveAvatar((AvatarComponent)target.WorldUI);
     }
 }
Exemple #45
0
 public VMPlacementResult(VMPlacementError status, VMEntity obj)
 {
     Status = status;
     Object = obj;
 }
Exemple #46
0
 public bool ExecuteEntryPoint(int entry,VMContext context,bool runImmediately,VMEntity stackOBJ)
 {
     return(ExecuteEntryPoint(entry,context,runImmediately,stackOBJ,null));
 }
Exemple #47
0
        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];
                target.SetRoom(65534);
                if (target is VMGameObject) ((ObjectComponent)target.WorldUI).ForceDynamic = true;
                CursorTiles[i] = vm.Context.CreateObjectInstance(0x00000437, new LotTilePos(target.Position), FSO.LotView.Model.Direction.NORTH, true).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;

            uint guid;
            var bobj = Group.BaseObject;
            guid = bobj.Object.OBJ.GUID;
            if (bobj.MasterDefinition != null) guid = bobj.MasterDefinition.GUID;
            var catalogItem = Content.Content.Get().WorldCatalog.GetItemByGUID(guid);
            if (catalogItem != null) Holding.Price = (int)catalogItem.Price;
        }
Exemple #48
0
        public VMPlacementResult GetAvatarPlace(VMEntity target, LotTilePos pos, Direction dir)
        {
            //avatars cannot be placed in slots under any circumstances, so we skip a few steps.

            VMObstacle footprint = target.GetObstacle(pos, dir);
            ushort room = GetRoomAt(pos);

            VMPlacementError status = VMPlacementError.Success;
            VMEntity statusObj = null;

            if (footprint == null || pos.Level < 1)
            {
                return new VMPlacementResult(status);
            }

            var objs = RoomInfo[room].Entities;
            foreach (var obj in objs)
            {
                if (obj.MultitileGroup == target.MultitileGroup) continue;
                var oFoot = obj.Footprint;

                if (oFoot != null && oFoot.Intersects(footprint)) //also ignore allow intersection trees?
                {
                    var flags = (VMEntityFlags)obj.GetValue(VMStackObjectVariable.Flags);
                    bool allowAvatars = ((flags & VMEntityFlags.DisallowPersonIntersection) == 0) && ((flags & VMEntityFlags.AllowPersonIntersection) > 0);
                    if (!allowAvatars)
                    {
                        status = VMPlacementError.CantIntersectOtherObjects;
                        statusObj = obj;
                        if (obj.EntryPoints[26].ActionFunction != 0) break; //select chairs immediately.
                    }
                }

            }
            return new VMPlacementResult(status, statusObj);
        }