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); }
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); }
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 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); } }
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)); }
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); }
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 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); }