public static void LoadBarraEnergia(ContentManager Content)
 {
     Barra_P1 = new BarraEnergia(Content);
     Barra_P2 = new BarraEnergia(Content);
     P1 = Players.Player_Manager.Player_Array[0];
     P2 = Players.Player_Manager.Player_Array[1];
     AjustaPosicaoBarraEnergia();
 }
        public static void LoadSelectStageMenu(ContentManager content)
        {
            Content = content;

            SelectedStage = Stages.St00;

            P1 = Players.Player_Manager.Player_Array[0];

            LoadAnimations();
        }
Esempio n. 3
0
 public override IAreaJob CreateAreaJob(Players.Player owner, Vector3Int min, Vector3Int max, int npcID = 0)
 {
     SetLayer(min, max, BuiltinBlocks.LumberArea, -1, owner);
     return(base.CreateAreaJob(owner, min, max, npcID));
 }
Esempio n. 4
0
        public static bool OutofBannerRange(ItemTypes.ItemType itemType, Pipliz.Vector3Int position, Players.Player player, out BlockEntities.Implementations.BannerTracker.Banner banner)
        {
            banner = null;
            if (Helpers.Player.ExactPermission(player, ultimatepermission))
            {
                return(true);
            }
            if (Helpers.Player.ExactPermission(player, permission))
            {
                return(true);
            }

            if (itemType == ItemTypes.GetType("banner"))
            {
                foreach (var item in ServerManager.ColonyTracker.ColoniesByID.Values)
                {
                    if (Vector3.Distance(new Vector3(position.x, position.y, position.z),
                                         new Vector3(item.Banners[0].Position.x, item.Banners[0].Position.y, item.Banners[0].Position.z)) < GetBannerRadius())
                    {
                        if (item.Owners[0] != player)
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }

            if (ServerManager.BlockEntityTracker.BannerTracker.TryGetClosest(position, out banner, GetBannerRadius()))
            {
                if (banner.Colony.Owners.ContainsByReference(player) == false)
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 5
0
        public static void PlayerClicked(Players.Player player, PlayerClickedData playerClickData)
        {
            if (playerClickData.IsConsumed || playerClickData.TypeSelected != Item.ItemIndex)
            {
                return;
            }

            var click      = playerClickData;
            var rayCastHit = click.GetVoxelHit();
            var ps         = PlayerState.GetPlayerState(player);

            if (!_WandModes.ContainsKey(ps))
            {
                _WandModes.Add(ps, WandMode.Horizontal);
            }

            if (click.ClickType != PlayerClickedData.EClickType.Right)
            {
                if (ps.BuildersWandPreview.Count != 0)
                {
                    foreach (var pos in ps.BuildersWandPreview)
                    {
                        if (World.TryGetTypeAt(pos, out ushort objType) && objType == Selector.ItemIndex)
                        {
                            ServerManager.TryChangeBlock(pos, ColonyBuiltIn.ItemTypes.AIR.Id, new BlockChangeRequestOrigin(player));
                        }
                    }

                    ps.BuildersWandPreview.Clear();
                    ps.BuildersWandTarget = ColonyBuiltIn.ItemTypes.AIR.Id;
                }
                else
                {
                    _WandModes[ps] = _WandModes[ps].Next();
                    PandaChat.Send(player, _localizationHelper, "WandMode", ChatColor.green, _WandModes[ps].ToString(), ps.BuildersWandCharge.ToString());
                }
            }
            else
            {
                if (ps.BuildersWandPreview.Count != 0)
                {
                    var stockpile  = player?.ActiveColony?.Stockpile;
                    var item       = ItemTypes.GetType(ps.BuildersWandTarget);
                    var removeItem = item.OnRemoveItems.FirstOrDefault();
                    foreach (var pos in ps.BuildersWandPreview)
                    {
                        if ((stockpile != null && stockpile.TryRemove(ps.BuildersWandTarget)) || player.Inventory.TryRemove(ps.BuildersWandTarget) ||
                            (removeItem.Type != 0 && stockpile != null && stockpile.TryRemove(removeItem.Type)) || (removeItem.Type != 0 && player.Inventory.TryRemove(removeItem.Type)))
                        {
                            ps.BuildersWandCharge--;
                            ServerManager.TryChangeBlock(pos, ps.BuildersWandTarget, new BlockChangeRequestOrigin(player));
                        }
                        else
                        {
                            ServerManager.TryChangeBlock(pos, ColonyBuiltIn.ItemTypes.AIR.Id, new BlockChangeRequestOrigin(player));
                        }
                    }

                    ps.BuildersWandPreview.Clear();
                    ps.BuildersWandTarget = ColonyBuiltIn.ItemTypes.AIR.Id;

                    if (ps.BuildersWandCharge <= 0)
                    {
                        var inv = player.Inventory;
                        inv.TryRemove(Item.ItemIndex);
                        ps.BuildersWandCharge = DURABILITY + ps.BuildersWandMaxCharge;
                        PandaChat.Send(player, _localizationHelper, "OutOfEnergy", ChatColor.red);
                    }
                }
                else
                {
                    var startingPos = rayCastHit.BlockHit;
                    ps.BuildersWandTarget = rayCastHit.TypeHit;

                    switch (_WandModes[ps])
                    {
                    case WandMode.Horizontal:

                        switch (rayCastHit.SideHit)
                        {
                        case VoxelSide.xMin:
                            startingPos = rayCastHit.BlockHit.Add(-1, 0, 0);
                            zxPos(ps, startingPos);
                            break;

                        case VoxelSide.xPlus:
                            startingPos = rayCastHit.BlockHit.Add(1, 0, 0);
                            zxNeg(ps, startingPos);
                            break;

                        case VoxelSide.zMin:
                            startingPos = rayCastHit.BlockHit.Add(0, 0, -1);
                            xzPos(ps, startingPos);
                            break;

                        case VoxelSide.zPlus:
                            startingPos = rayCastHit.BlockHit.Add(0, 0, 1);
                            xzNeg(ps, startingPos);
                            break;

                        case VoxelSide.yMin:
                            startingPos = rayCastHit.BlockHit.Add(0, -1, 0);
                            xyPos(ps, startingPos);
                            zyPos(ps, startingPos, true);
                            break;

                        case VoxelSide.yPlus:
                            startingPos = rayCastHit.BlockHit.Add(0, 1, 0);
                            xyNeg(ps, startingPos);
                            zyNeg(ps, startingPos, true);
                            break;
                        }

                        break;

                    case WandMode.Vertical:

                        switch (rayCastHit.SideHit)
                        {
                        case VoxelSide.xMin:
                            startingPos = rayCastHit.BlockHit.Add(-1, 0, 0);
                            yxPos(ps, startingPos);
                            break;

                        case VoxelSide.xPlus:
                            startingPos = rayCastHit.BlockHit.Add(1, 0, 0);
                            yxNeg(ps, startingPos);
                            break;

                        case VoxelSide.zMin:
                            startingPos = rayCastHit.BlockHit.Add(0, 0, -1);
                            yzPos(ps, startingPos);
                            break;

                        case VoxelSide.zPlus:
                            startingPos = rayCastHit.BlockHit.Add(0, 0, 1);
                            yzNeg(ps, startingPos);
                            break;

                        default:
                            PandaChat.Send(player, _localizationHelper, "NotValidTopOrBottom", ChatColor.red, _WandModes[ps].ToString());
                            break;
                        }

                        break;

                    case WandMode.TopAndBottomX:

                        switch (rayCastHit.SideHit)
                        {
                        case VoxelSide.yMin:
                            startingPos = rayCastHit.BlockHit.Add(0, -1, 0);
                            xyPos(ps, startingPos);
                            break;

                        case VoxelSide.yPlus:
                            startingPos = rayCastHit.BlockHit.Add(0, 1, 0);
                            xyNeg(ps, startingPos);
                            break;

                        case VoxelSide.xMin:
                            startingPos = rayCastHit.BlockHit.Add(-1, 0, 0);
                            xyNeg(ps, startingPos);
                            break;

                        case VoxelSide.xPlus:
                            startingPos = rayCastHit.BlockHit.Add(1, 0, 0);
                            xyNeg(ps, startingPos);
                            break;

                        case VoxelSide.zMin:
                            startingPos = rayCastHit.BlockHit.Add(0, 0, -1);
                            xyNeg(ps, startingPos);
                            break;

                        case VoxelSide.zPlus:
                            startingPos = rayCastHit.BlockHit.Add(0, 0, 1);
                            xyNeg(ps, startingPos);
                            break;

                        default:
                            PandaChat.Send(player, _localizationHelper, "NotValidTopOrBottom", ChatColor.red, _WandModes[ps].ToString());
                            break;
                        }

                        break;

                    case WandMode.TopAndBottomZ:

                        switch (rayCastHit.SideHit)
                        {
                        case VoxelSide.yMin:
                            startingPos = rayCastHit.BlockHit.Add(0, -1, 0);
                            zyPos(ps, startingPos);
                            break;

                        case VoxelSide.yPlus:
                            startingPos = rayCastHit.BlockHit.Add(0, 1, 0);
                            zyNeg(ps, startingPos);
                            break;

                        case VoxelSide.xMin:
                            startingPos = rayCastHit.BlockHit.Add(-1, 0, 0);
                            zyNeg(ps, startingPos);
                            break;

                        case VoxelSide.xPlus:
                            startingPos = rayCastHit.BlockHit.Add(1, 0, 0);
                            zyNeg(ps, startingPos);
                            break;

                        case VoxelSide.zMin:
                            startingPos = rayCastHit.BlockHit.Add(0, 0, -1);
                            zyNeg(ps, startingPos);
                            break;

                        case VoxelSide.zPlus:
                            startingPos = rayCastHit.BlockHit.Add(0, 0, 1);
                            zyNeg(ps, startingPos);
                            break;

                        default:
                            PandaChat.Send(player, _localizationHelper, "NotValidTopOrBottom", ChatColor.red, _WandModes[ps].ToString());
                            break;
                        }

                        break;
                    }
                }
            }
        }
Esempio n. 6
0
 public IPandaBoss GetNewBoss(Path path, Players.Player p)
 {
     return(new FallenRanger(path, p));
 }
Esempio n. 7
0
 public virtual ITrackableBlock InitializeOnAdd(Vector3Int position, ushort type, Players.Player player)
 {
     blockInventory = new NPCInventory(10000000f);
     InitializeJob(player, position, 0);
     return(this);
 }
 protected override void Process(Players.Player source, Players.Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs inResponseTo)
 {
     throw new NotImplementedException();
 }
Esempio n. 9
0
        public static void OnChange(Vector3Int position, ushort typeOld, ushort typeNew, Players.Player player)
        {
            Herbs herb = BlockTracker.Get <Herbs>(position);

            if (herb != null)
            {
                if (typeNew == Jobs.HerbalistRegister.HerbStage1.ItemIndex)
                {
                    herb.type = HerbType.Stage1;
                }
                else
                {
                    herb.type = HerbType.Invalid;
                }
            }
        }
Esempio n. 10
0
 public static void OnRemove(Vector3Int position, ushort type, Players.Player player)
 {
     BlockTracker.Remove(position);
 }
        public virtual void OnNPCAtJob(BlockJobInstance blockJobInstance, ref NPCState state)
        {
            ScientistJobInstance instance = blockJobInstance as ScientistJobInstance;

            if (instance == null)
            {
                state.JobIsDone = true;
                return;
            }

            Colony owner = instance.Owner;

            instance.NPC.LookAt(instance.Position.Vector);
            ColonyScienceState scienceData = owner.ScienceData;

            state.JobIsDone = true;

            // if no stored items - check if the stockpile contains the items required for any of the researches
            var completedCycles = scienceData.CompletedCycles;

            if (instance.StoredItemCount <= 0)
            {
                if (completedCycles.Count == 0)
                {
                    // done for now
                    state.SetIndicator(new Shared.IndicatorState(Random.NextFloat(8f, 16f), BuiltinBlocks.Indices.erroridle));
                    return;
                }

                int possibles = 0;
                for (int i = 0; i < completedCycles.Count; i++)
                {
                    ScienceKey cyclesResearch = completedCycles.GetKeyAtIndex(i);
                    if (cyclesResearch.Researchable.TryGetCyclesCondition(out ScientistCyclesCondition cyclesData) && completedCycles.GetValueAtIndex(i) < cyclesData.CycleCount)
                    {
                        possibles++;
                        if (owner.Stockpile.Contains(cyclesData.ItemsPerCycle))
                        {
                            instance.ShouldTakeItems = true;
                            state.SetCooldown(0.3);
                            return;                             // found an in-progress research that we have items for
                        }
                    }
                }

                // missing items, find random requirement to use as indicator
                if (possibles > 0)
                {
                    int possiblesIdx = Random.Next(0, possibles);

                    for (int i = 0; i < completedCycles.Count; i++)
                    {
                        ScienceKey cyclesResearch = completedCycles.GetKeyAtIndex(i);
                        if (cyclesResearch.Researchable.TryGetCyclesCondition(out ScientistCyclesCondition cyclesData) && completedCycles.GetValueAtIndex(i) < cyclesData.CycleCount)
                        {
                            if (possiblesIdx-- <= 0)
                            {
                                MissingItemHelper(cyclesData.ItemsPerCycle, owner.Stockpile, ref state);
                                return;
                            }
                        }
                    }
                    // should be unreachable
                }

                // done for now
                state.SetIndicator(new Shared.IndicatorState(Random.NextFloat(8f, 16f), BuiltinBlocks.Indices.erroridle));
                return;
            }

            // have stored items, try to forward an active science

            if (completedCycles.Count == 0)
            {
                instance.StoredItemCount = 0;
                state.SetCooldown(0.3);
                return;
            }

            var   happyData        = owner.HappinessData;
            float cyclesToAdd      = happyData.ScienceSpeedMultiplierCalculator.GetSpeedMultiplier(happyData.CachedHappiness, instance.NPC);
            int   doneScienceIndex = -1;

            const float MINIMUM_CYCLES_TO_ADD = 0.001f;

            if (cyclesToAdd <= MINIMUM_CYCLES_TO_ADD)
            {
                state.SetIndicator(new Shared.IndicatorState(CraftingCooldown, BuiltinBlocks.Indices.missingerror));
                Log.WriteWarning($"Cycles below minimum for science job at {instance.Position}!");
                return;
            }

            for (int i = 0; i < completedCycles.Count && cyclesToAdd >= 0f; i++)
            {
                AbstractResearchable research = completedCycles.GetKeyAtIndex(i).Researchable;
                float progress = completedCycles.GetValueAtIndex(i);

                if (!research.TryGetCyclesCondition(out ScientistCyclesCondition cyclesCondition) || progress >= cyclesCondition.CycleCount)
                {
                    continue;
                }

                bool  atCycleBoundary = Math.Abs(progress - Math.RoundToInt(progress)) < MINIMUM_CYCLES_TO_ADD;
                float freeCycles      = (float)System.Math.Ceiling(progress) - progress;
                if (!atCycleBoundary)
                {
                    if (cyclesToAdd <= freeCycles)
                    {
                        OnDoFullCycles(ref state);                         // cycles <= freecycles, just add all
                        return;
                    }
                    else
                    {
                        OnDoPartialCycles(ref state, Math.Min(freeCycles, cyclesToAdd));
                    }
                }

                if (progress >= cyclesCondition.CycleCount)
                {
                    // completed on a partial cycle (it wasn't completed a few lines up)
                    continue;
                }

                // at boundary and/or will cross a boundary with the cyclesToAdd

                List <InventoryItem> requirements = cyclesCondition.ItemsPerCycle;

                if (owner.Stockpile.TryRemove(requirements))
                {
                    // got the items, deal with recycling, then just add the full cyclesToAdd
                    int recycled = 0;
                    for (int j = 0; j < requirements.Count; j++)
                    {
                        ushort type = requirements[j].Type;
                        if (type == BuiltinBlocks.Indices.sciencebaglife ||
                            type == BuiltinBlocks.Indices.sciencebagbasic ||
                            type == BuiltinBlocks.Indices.sciencebagmilitary
                            )
                        {
                            recycled += requirements[j].Amount;
                        }
                    }
                    for (int j = recycled; j > 0; j--)
                    {
                        if (Random.NextDouble() > RECYCLE_CHANCE)
                        {
                            recycled--;
                        }
                    }
                    if (recycled > 0)
                    {
                        owner.Stockpile.Add(BuiltinBlocks.Indices.linenbag, recycled);
                    }
                    OnDoFullCycles(ref state);
                    return;
                }
                continue;

                // unreachable
                void OnDoFullCycles(ref NPCState stateCopy)
                {
                    scienceData.CyclesAddProgress(research.AssignedKey, cyclesToAdd);
                    stateCopy.SetIndicator(new Shared.IndicatorState(CraftingCooldown, NPCIndicatorType.Science, (ushort)research.AssignedKey.Index));
                    instance.StoredItemCount--;
                    progress += cyclesToAdd;
                    if (progress >= cyclesCondition.CycleCount && research.AreConditionsMet(scienceData))
                    {
                        SendCompleteMessage();
                    }
                }

                void OnDoPartialCycles(ref NPCState stateCopy, float cyclesToUse)
                {
                    cyclesToAdd -= cyclesToUse;
                    scienceData.CyclesAddProgress(research.AssignedKey, cyclesToUse);
                    progress += cyclesToUse;
                    if (progress >= cyclesCondition.CycleCount && research.AreConditionsMet(scienceData))
                    {
                        SendCompleteMessage();
                    }
                    doneScienceIndex = (int)research.AssignedKey.Index;
                }

                void SendCompleteMessage()
                {
                    Players.Player[] owners = owner.Owners;
                    for (int j = 0; j < owners.Length; j++)
                    {
                        Players.Player player = owners[j];
                        if (player.ConnectionState == Players.EConnectionState.Connected && player.ActiveColony == owner)
                        {
                            string msg = Localization.GetSentence(player.LastKnownLocale, "chat.onscienceready");
                            string res = Localization.GetSentence(player.LastKnownLocale, research.GetKey() + ".name");
                            msg = string.Format(msg, res);
                            Chatting.Chat.Send(player, msg);
                        }
                    }
                }
            }

            if (doneScienceIndex >= 0)
            {
                // did some freecoasting
                state.SetIndicator(new Shared.IndicatorState(CraftingCooldown, NPCIndicatorType.Science, (ushort)doneScienceIndex));
                instance.StoredItemCount--;
                return;
            }

            // had stored items, but for some reason couldn't dump them in existing research
            // reset the job basically
            instance.StoredItemCount = 0;
            state.SetCooldown(0.3);
            return;

            void MissingItemHelper(IList <InventoryItem> requirements, Stockpile stockpile, ref NPCState stateCopy)
            {
                ushort missing = 0;

                for (int i = 0; i < requirements.Count; i++)
                {
                    if (!stockpile.Contains(requirements[i]))
                    {
                        missing = requirements[i].Type;
                        break;
                    }
                }
                float cooldown = Random.NextFloat(8f, 16f);

                stateCopy.SetIndicator(new Shared.IndicatorState(cooldown, missing, true, false));
                stateCopy.JobIsDone = false;
            }
        }
Esempio n. 12
0
 public string GetQuestText(Colony colony, Players.Player player)
 {
     return(LocalizationHelper.LocalizeOrDefault(QuestTextSentenceKey, player));
 }
Esempio n. 13
0
 public static bool ExactPermission(Players.Player player, string permission)
 {
     return(PermissionsManager.HasPermissionExact(player, permission));
 }
Esempio n. 14
0
 public static bool CheckPermission(Players.Player player, string permission)
 {
     return(PermissionsManager.CheckAndWarnPermission(player, permission));
 }
 public ITrackableBlock InitializeOnAdd(Vector3Int position, ushort type, Players.Player player)
 {
     blockType = type;
     InitializeJob(player, position, 0);
     return(this);
 }
 public override ITrackableBlock InitializeFromJSON(Players.Player player, JSONNode node)
 {
     blockType = ItemTypes.IndexLookup.GetIndex(node.GetAsOrDefault("type", "air"));
     InitializeJob(player, (Vector3Int)node["position"], node.GetAs <int>("npcID"));
     return(this);
 }
 public void OnChangeAction(Vector3Int position, ushort wasType, ushort newType, Players.Player causedBy)
 {
 }
Esempio n. 18
0
 public void SetPlayerSkin(Players.Player player)
 {
     _skinHelper.SetSkin(player.SkinIndex);
 }
Esempio n. 19
0
 /// <summary>
 /// Tracking new block placed in the world
 /// </summary>
 public virtual IGrowableBlock MakeGrowableBlock(Vector3Int position, ushort type, Players.Player player)
 {
     return(new GrowableBlock <T>(position, Random.NextFloat(0f, RandomStartGrowthMax * Stages[0].GrowthTime)));
 }
Esempio n. 20
0
 protected abstract void Update(Players.Player player);
Esempio n. 21
0
 public override ITrackableBlock InitializeFromJSON(Players.Player player, JSONNode node)
 {
     blockInventory = new NPCInventory(node["inventory"]);
     InitializeJob(player, (Vector3Int)node["position"], node.GetAs <int>("npcID"));
     return(this);
 }
Esempio n. 22
0
        public bool TryDoCommand(Players.Player player, string chat)
        {
            if (player == null || player.ID == NetworkID.Server)
            {
                return(true);
            }

            string[]    array  = CommandManager.SplitCommand(chat);
            Colony      colony = Colony.Get(player);
            PlayerState state  = PlayerState.GetPlayerState(player);

            state.CallToArmsEnabled = !state.CallToArmsEnabled;

            if (state.CallToArmsEnabled)
            {
                PandaChat.Send(player, "Call to arms activated!", ChatColor.red, ChatStyle.bold);

                foreach (var follower in colony.Followers)
                {
                    var job = follower.Job;

                    if (!CanCallToArms(job))
                    {
                        continue;
                    }

                    try
                    {
                        if (job != null)
                        {
                            if (job.GetType() != typeof(CalltoArmsJob))
                            {
                                _Jobs[follower] = job;
                            }

                            job.OnRemovedNPC();
                            follower.ClearJob();
                        }
                    }
                    catch (Exception ex)
                    {
                        PandaLogger.LogError(ex);
                    }

                    var armsJob = new CalltoArmsJob();
                    _callToArmsJobs.Add(armsJob);
                    armsJob.OnAssignedNPC(follower);
                    follower.TakeJob(armsJob);
                }
            }
            else
            {
                PandaChat.Send(player, "Call to arms deactivated.", ChatColor.green, ChatStyle.bold);
                List <NPCBase> assignedWorkers = new List <NPCBase>();

                foreach (var follower in colony.Followers)
                {
                    var job = follower.Job;

                    if (job != null && job.GetType() == typeof(CalltoArmsJob))
                    {
                        follower.ClearJob();
                        job.OnRemovedNPC();
                        ((JobTracker.JobFinder)JobTracker.GetOrCreateJobFinder(player)).openJobs.Remove(job);
                    }

                    if (_Jobs.ContainsKey(follower) && _Jobs[follower].NeedsNPC)
                    {
                        assignedWorkers.Add(follower);
                        follower.TakeJob(_Jobs[follower]);
                        _Jobs[follower].OnAssignedNPC(follower);
                        JobTracker.Remove(player, _Jobs[follower].KeyLocation);
                    }
                }

                _Jobs.Clear();
            }

            foreach (var armsJob in _callToArmsJobs)
            {
                ((JobTracker.JobFinder)JobTracker.GetOrCreateJobFinder(player)).openJobs.Remove(armsJob);
            }

            _callToArmsJobs.Clear();
            JobTracker.Update();
            Colony.SendColonistCount(player);

            return(true);
        }
Esempio n. 23
0
        public static void PlayerClicked(Players.Player player, Box <PlayerClickedData> boxedData)
        {
            if (boxedData.item1.IsConsumed || boxedData.item1.typeSelected != Item.ItemIndex)
            {
                return;
            }

            var click      = boxedData.item1;
            var rayCastHit = click.rayCastHit;
            var ps         = PlayerState.GetPlayerState(player);

            if (click.clickType != PlayerClickedData.ClickType.Right)
            {
                if (ps.BuildersWandPreview.Count != 0)
                {
                    foreach (var pos in ps.BuildersWandPreview)
                    {
                        if (World.TryGetTypeAt(pos, out var objType) && objType == Selector.ItemIndex)
                        {
                            ServerManager.TryChangeBlock(pos, BuiltinBlocks.Air);
                        }
                    }

                    ps.BuildersWandPreview.Clear();
                    ps.BuildersWandTarget = BuiltinBlocks.Air;
                }
                else
                {
                    ps.BuildersWandMode = ps.BuildersWandMode.Next();

                    PandaChat.Send(player,
                                   $"Wand mode set to {ps.BuildersWandMode}. Charge Left: {ps.BuildersWandCharge}",
                                   ChatColor.green);
                }
            }
            else
            {
                if (ps.BuildersWandPreview.Count != 0)
                {
                    var stockpile = Stockpile.GetStockPile(player);

                    foreach (var pos in ps.BuildersWandPreview)
                    {
                        if (stockpile.TryRemove(ps.BuildersWandTarget))
                        {
                            ps.BuildersWandCharge--;
                            ServerManager.TryChangeBlock(pos, ps.BuildersWandTarget);
                        }
                        else
                        {
                            ServerManager.TryChangeBlock(pos, BuiltinBlocks.Air);
                        }
                    }

                    ps.BuildersWandPreview.Clear();
                    ps.BuildersWandTarget = BuiltinBlocks.Air;

                    if (ps.BuildersWandCharge <= 0)
                    {
                        var inv = Inventory.GetInventory(player);
                        inv.TryRemove(Item.ItemIndex);
                        ps.BuildersWandCharge = DURABILITY + ps.BuildersWandMaxCharge;

                        PandaChat.Send(player,
                                       "Your Builders wand has Run out of energy and turns to dust in your hands.",
                                       ChatColor.red);
                    }
                }
                else
                {
                    var startingPos = click.VoxelHit;
                    ps.BuildersWandTarget = click.typeHit;

                    switch (ps.BuildersWandMode)
                    {
                    case WandMode.Horizontal:

                        switch (click.VoxelSideHit)
                        {
                        case VoxelSide.xMin:
                            startingPos = click.VoxelHit.Add(-1, 0, 0);
                            zxPos(ps, startingPos);
                            break;

                        case VoxelSide.xPlus:
                            startingPos = click.VoxelHit.Add(1, 0, 0);
                            zxNeg(ps, startingPos);
                            break;

                        case VoxelSide.zMin:
                            startingPos = click.VoxelHit.Add(0, 0, -1);
                            xzPos(ps, startingPos);
                            break;

                        case VoxelSide.zPlus:
                            startingPos = click.VoxelHit.Add(0, 0, 1);
                            xzNeg(ps, startingPos);
                            break;

                        case VoxelSide.yMin:
                            startingPos = click.VoxelHit.Add(0, -1, 0);
                            xyPos(ps, startingPos);
                            zyPos(ps, startingPos, true);
                            break;

                        case VoxelSide.yPlus:
                            startingPos = click.VoxelHit.Add(0, 1, 0);
                            xyNeg(ps, startingPos);
                            zyNeg(ps, startingPos, true);
                            break;
                        }

                        break;

                    case WandMode.Vertical:

                        switch (click.VoxelSideHit)
                        {
                        case VoxelSide.xMin:
                            startingPos = click.VoxelHit.Add(-1, 0, 0);
                            yxPos(ps, startingPos);
                            break;

                        case VoxelSide.xPlus:
                            startingPos = click.VoxelHit.Add(1, 0, 0);
                            yxNeg(ps, startingPos);
                            break;

                        case VoxelSide.zMin:
                            startingPos = click.VoxelHit.Add(0, 0, -1);
                            yzPos(ps, startingPos);
                            break;

                        case VoxelSide.zPlus:
                            startingPos = click.VoxelHit.Add(0, 0, 1);
                            yzNeg(ps, startingPos);
                            break;

                        default:

                            PandaChat.Send(player,
                                           $"Building on top or bottom of a block not valid for wand mode: {ps.BuildersWandMode}.",
                                           ChatColor.red);

                            break;
                        }

                        break;

                    case WandMode.TopAndBottomX:

                        switch (click.VoxelSideHit)
                        {
                        case VoxelSide.yMin:
                            startingPos = click.VoxelHit.Add(0, -1, 0);
                            xyPos(ps, startingPos);
                            break;

                        case VoxelSide.yPlus:
                            startingPos = click.VoxelHit.Add(0, 1, 0);
                            xyNeg(ps, startingPos);
                            break;

                        case VoxelSide.xMin:
                            startingPos = click.VoxelHit.Add(-1, 0, 0);
                            xyNeg(ps, startingPos);
                            break;

                        case VoxelSide.xPlus:
                            startingPos = click.VoxelHit.Add(1, 0, 0);
                            xyNeg(ps, startingPos);
                            break;

                        case VoxelSide.zMin:
                            startingPos = click.VoxelHit.Add(0, 0, -1);
                            xyNeg(ps, startingPos);
                            break;

                        case VoxelSide.zPlus:
                            startingPos = click.VoxelHit.Add(0, 0, 1);
                            xyNeg(ps, startingPos);
                            break;

                        default:

                            PandaChat.Send(player,
                                           $"Building on top or bottom of a block not valid for wand mode: {ps.BuildersWandMode}.",
                                           ChatColor.red);

                            break;
                        }

                        break;

                    case WandMode.TopAndBottomZ:

                        switch (click.VoxelSideHit)
                        {
                        case VoxelSide.yMin:
                            startingPos = click.VoxelHit.Add(0, -1, 0);
                            zyPos(ps, startingPos);
                            break;

                        case VoxelSide.yPlus:
                            startingPos = click.VoxelHit.Add(0, 1, 0);
                            zyNeg(ps, startingPos);
                            break;

                        case VoxelSide.xMin:
                            startingPos = click.VoxelHit.Add(-1, 0, 0);
                            zyNeg(ps, startingPos);
                            break;

                        case VoxelSide.xPlus:
                            startingPos = click.VoxelHit.Add(1, 0, 0);
                            zyNeg(ps, startingPos);
                            break;

                        case VoxelSide.zMin:
                            startingPos = click.VoxelHit.Add(0, 0, -1);
                            zyNeg(ps, startingPos);
                            break;

                        case VoxelSide.zPlus:
                            startingPos = click.VoxelHit.Add(0, 0, 1);
                            zyNeg(ps, startingPos);
                            break;

                        default:

                            PandaChat.Send(player,
                                           $"Building on top or bottom of a block not valid for wand mode: {ps.BuildersWandMode}.",
                                           ChatColor.red);

                            break;
                        }

                        break;
                    }
                }
            }
        }
Esempio n. 24
0
 protected override bool VerifyCard(Players.Player source, Card card)
 {
     return(true);
 }
Esempio n. 25
0
        public bool TryDoCommand(Players.Player player, string chat, List <string> split)
        {
            if (!chat.StartsWith("/armor", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            var colony = player.ActiveColony;
            var counts = new Dictionary <string, Dictionary <ArmorFactory.ArmorSlot, int> >();

            foreach (var npc in colony.Followers)
            {
                var inv = Get(npc);

                foreach (var item in inv.Armor)
                {
                    if (!item.Value.IsEmpty())
                    {
                        var armor = ArmorFactory.ArmorLookup[item.Value.Id];

                        if (!counts.ContainsKey(armor.name))
                        {
                            counts.Add(armor.name, new Dictionary <ArmorFactory.ArmorSlot, int>());
                        }

                        if (!counts[armor.name].ContainsKey(armor.Slot))
                        {
                            counts[armor.name].Add(armor.Slot, 0);
                        }

                        counts[armor.name][armor.Slot]++;
                    }
                }
            }

            var state = PlayerState.GetPlayerState(player);
            var psb   = new StringBuilder();

            psb.Append("Player =>");

            foreach (var armor in state.Armor)
            {
                if (armor.Value.IsEmpty())
                {
                    psb.Append($" {armor.Key}: None |");
                }
                else
                {
                    psb.Append($" {armor.Key}: {ArmorFactory.ArmorLookup[armor.Value.Id].name} | ");
                }
            }

            PandaChat.Send(player, _localizationHelper, psb.ToString());

            foreach (var type in counts)
            {
                var sb = new StringBuilder();
                sb.Append($"{type.Key} =>");
                foreach (var slot in type.Value)
                {
                    sb.Append($" {slot.Key}: {slot.Value} |");
                }

                PandaChat.Send(player, _localizationHelper, sb.ToString());
            }

            return(true);
        }
Esempio n. 26
0
 protected override bool VerifyPlayer(Players.Player source, Players.Player player)
 {
     return(true);
 }
Esempio n. 27
0
 static bool ChopTree(Vector3Int p, Players.Player owner)
 {
     return(ServerManager.TryChangeBlock(p, 0, owner) &&
            ServerManager.TryChangeBlock(p.Add(0, 1, 0), 0, owner) &&
            ServerManager.TryChangeBlock(p.Add(0, 2, 0), 0, owner));
 }
Esempio n. 28
0
 protected abstract bool?SaveLifeVerify(Players.Player source, List <Card> cards, List <Players.Player> players);
Esempio n. 29
0
 public override void OnRightClickOn(Players.Player player, Pipliz.Box <Shared.PlayerClickedData> boxedData)
 {
     base.OnRightClickOn(player, boxedData);
 }
Esempio n. 30
0
        public bool TryDoCommand(Players.Player causedBy, string chattext, List <string> splits)
        {
            if (!splits[0].Equals("/beds"))
            {
                return(false);
            }
            if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "beds"))
            {
                return(true);
            }

            var m = Regex.Match(chattext, @"/beds (?<amount>\d+)");

            if (!m.Success)
            {
                Chat.Send(causedBy, "Syntax: /beds {number}");
                return(true);
            }
            int amount = 0;

            if (!int.TryParse(m.Groups["amount"].Value, out amount) || amount <= 0)
            {
                Chat.Send(causedBy, "Number should be > 0");
                return(true);
            }

            Colony colony = causedBy.ActiveColony;

            if (colony == null)
            {
                Chat.Send(causedBy, "You need to be at an active colony to spawn beds");
                return(true);
            }
            BannerTracker.Banner banner = colony.GetClosestBanner(causedBy.VoxelPosition);
            if (banner == null)
            {
                Chat.Send(causedBy, "No banners found for the active colony");
                return(true);
            }

            Chat.Send(causedBy, $"Placing {amount} beds around you");
            int        radius = 3;
            Vector3Int pos = banner.Position.Add(-radius + 1, 0, -radius);
            int        counterX = -radius + 1, counterZ = -radius;
            int        bedUsed = 0;
            int        stepX = 1, stepZ = 0;

            while (amount > 0)
            {
                ushort blockType;
                if (World.TryGetTypeAt(pos, out blockType) && blockType == BuiltinBlocks.Indices.air &&
                    ServerManager.TryChangeBlock(pos, bedBlocks[bedUsed], causedBy) == EServerChangeBlockResult.Success)
                {
                    --amount;
                }
                if (counterX == -radius && counterZ == -radius)
                {
                    stepX    = 1;
                    stepZ    = 0;
                    radius  += 2;
                    counterZ = -radius;
                    counterX = -radius;
                    bedUsed  = 0;
                    pos      = pos.Add(-2, 0, -2);
                }
                else if (counterX == radius && counterZ == -radius)
                {
                    stepX   = 0;
                    stepZ   = 1;
                    bedUsed = 1;
                }
                else if (counterX == radius && counterZ == radius)
                {
                    stepX   = -1;
                    stepZ   = 0;
                    bedUsed = 2;
                }
                else if (counterX == -radius && counterZ == radius)
                {
                    stepX   = 0;
                    stepZ   = -1;
                    bedUsed = 3;
                }
                counterX += stepX;
                counterZ += stepZ;
                pos       = pos.Add(stepX, 0, stepZ);
            }

            return(true);
        }
 public void OnRemoveAction(Vector3Int position, ushort wasType, Players.Player causedBy)
 {
     Managers.CropManager.untrackCrop(position, this);
 }
Esempio n. 32
0
 public IPandaBoss GetNewBoss(Path path, Players.Player p)
 {
     return(new Bulging(path, p));
 }