Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public override void OnAreaValid(GameActionPack pack, Player player, Vector3i position, Quaternion rotation)
        {
            var deed = PropertyManager.FindConnectedDeedOrCreate(player.User, position.XZ);

            foreach (var plotPosition in PlotUtil.GetAllPropertyPos(position, virtualOccupancy))
            {
                if (!this.IsPlotAuthorized(plotPosition, player.User, out var canClaimPlot))
                {
                    return;
                }

                if (canClaimPlot)
                {
                    pack.ClaimProperty(deed, player.User, player.User.Inventory, plotPosition, requirePapers: false);
                }
            }

            if (!pack.EarlyResult)
            {
                return;
            }

            pack.AddPostEffect(() =>
            {
                var camp      = WorldObjectManager.ForceAdd(typeof(CampsiteObject), player.User, position, rotation, false);
                var stockpile = WorldObjectManager.ForceAdd(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(), false);
                var storage   = camp.GetComponent <PublicStorageComponent>();
                var changeSet = new InventoryChangeSet(storage.Inventory);
                PlayerDefaults.GetDefaultCampsiteInventory().ForEach(x => changeSet.AddItems(x.Key, x.Value, storage.Inventory));

                //If we're running a settlement system, create the homestead item now and fill it with homestead-specific claim papers.
                if (SettlementPluginConfig.Obj.SettlementSystemEnabled)
                {
                    var marker     = WorldObjectManager.ForceAdd(typeof(HomesteadMarkerObject), player.User, position + rotation.RotateVector(new Vector3i(3, 0, 3)), rotation, false);
                    var markerComp = marker.GetComponent <SettlementMarkerComponent>();
                    markerComp.Settlement.Citizenship.AddSpawnedClaims(this.bonusPapers);
                    markerComp.UpdateSpawnedClaims();
                }
                else
                {
                    //For the old system, add the papers to the tent.
                    if (this.bonusPapers > 0)
                    {
                        changeSet.AddItems(typeof(PropertyClaimItem), this.bonusPapers);
                    }
                }
                changeSet.Apply();
            });
        }
        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);
        }