예제 #1
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);
            }
            obj.SetRoom(room);
            if (obj.GetValue(VMStackObjectVariable.LightingContribution) > 0)
            {
                RefreshLighting(room, true);
            }

            SetToNextCache.RegisterObjectPos(obj);
        }
예제 #2
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);
            }
            obj.SetRoom(room);
            if (obj.GetValue(VMStackObjectVariable.LightingContribution) > 0)
            {
                RefreshLighting(room, true);
            }

            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);
        }
예제 #3
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);
        }
예제 #4
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);
            }
        }
예제 #5
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));
        }
예제 #6
0
파일: VMContext.cs 프로젝트: Daribon/FreeSO
        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);
        }
예제 #7
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);
        }
예제 #8
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);
            }
            obj.SetRoom(room);
            if (obj.GetValue(VMStackObjectVariable.LightingContribution) > 0)
                RefreshLighting(room, true);

            SetToNextCache.RegisterObjectPos(obj);
        }