public override Result OnAreaValid(Player player, Vector3i position, Quaternion rotation) { Deed deed = PropertyManager.FindNearbyDeedOrCreate(player.User, position.XZ); foreach (var plot in WorldObject.GetOccupiedPropertyPositions(typeof(StarterCampObject), position, rotation)) { PropertyManager.Claim(deed.Id, player.User, player.User.Inventory, plot); } var camp = WorldObjectManager.TryToAdd(typeof(CampsiteObject), player.User, position, rotation, false); var stockpile = WorldObjectManager.TryToAdd(typeof(TinyStockpileObject), player.User, position + rotation.RotateVector(Vector3i.Right * 3), rotation, false); player.User.OnWorldObjectPlaced.Invoke(camp); player.User.Markers.Add(camp.Position3i + Vector3i.Up, camp.UILinkContent()); player.User.Markers.Add(stockpile.Position3i + Vector3i.Up, stockpile.UILinkContent()); var storage = camp.GetComponent <PublicStorageComponent>(); var changeSet = new InventoryChangeSet(storage.Inventory); PlayerDefaults.GetDefaultCampsiteInventory().ForEach(x => { changeSet.AddItems(x.Key, x.Value, storage.Inventory); }); changeSet.Apply(); return(Result.Succeeded); }
// Place to claim public override InteractResult OnActRight(InteractionContext context) { Vector2i?position = this.GetPosition(context); Player player = context.Player; if (!position.HasValue) { return(InteractResult.NoOp); } Deed deed = PropertyManager.FindNearbyDeedOrCreate(player.User, position.Value); Result claimResult = PropertyManager.Claim(deed.Id, player.User, position.Value); if (!claimResult.Success && !deed.OwnedObjects.Any()) { PropertyManager.TryRemoveDeed(deed); } return((InteractResult)claimResult); }
public override Result OnAreaValid(Player player, Vector3i position, Quaternion rotation) { Result authAtPosOne = AuthManager.IsAuthorized(position, player.User); Result authAtPosTwo = AuthManager.IsAuthorized((position + rotation.RotateVector(Vector3i.Right * 3)).Round, player.User); if (!authAtPosOne.Success) { return(authAtPosOne); } else if (!authAtPosTwo.Success) { return(authAtPosTwo); } Deed deed = PropertyManager.FindNearbyDeedOrCreate(player.User, position.XZ); var dist = position.XZ - World.GetPropertyPos(position.XZ) - (World.PropertyPlotLength / 2); if (dist.x == 0 || dist.y == 0) { dist = rotation.RotateVector(new Vector3i(1, 0, 1)).XZi; } dist = new Vector2i(Math.Sign(dist.x), Math.Sign(dist.y)); Vector2i.XYIter(2).ForEach(x => PropertyManager.Claim(deed.Id, player.User, position.XZ + (new Vector2i(dist.x * x.x, dist.y * x.y) * World.PropertyPlotLength))); var camp = WorldObjectManager.TryToAdd(typeof(CampsiteObject), player.User, position, rotation, false); var stockpile = WorldObjectManager.TryToAdd(typeof(TinyStockpileObject), player.User, position + rotation.RotateVector(Vector3i.Right * 3), rotation, false); player.User.OnWorldObjectPlaced.Invoke(camp); player.User.Markers.Add(camp.Position3i + Vector3i.Up, camp.UILinkContent()); player.User.Markers.Add(stockpile.Position3i + Vector3i.Up, stockpile.UILinkContent()); var storage = camp.GetComponent <PublicStorageComponent>(); var changeSet = new InventoryChangeSet(storage.Inventory); PlayerDefaults.GetDefaultCampsiteInventory().ForEach(x => { changeSet.AddItems(x.Key, x.Value, storage.Inventory); }); changeSet.Apply(); return(Result.Succeeded); }