Esempio n. 1
0
        private bool ReFundChatCommand(IcPlayer player, string command, IDATokenClass text, TextMessageEnum chatType, object data)
        {
            // Acronym for a building is specified
            if (text.Size > 0)
            {
                string acronym = text[1];
                MappedBuildingDefinition       mappedDefinition = FindMappedDefinition(acronym);
                ICollection <IDefinitionClass> validatedDefinitions;
                if (mappedDefinition == null || (validatedDefinitions = mappedDefinition.ValidatedDefinitions) == null)
                {
                    DA.PagePlayer(player, $"No building found for acronym '{acronym}'.");

                    return(false);
                }

                IScriptableGameObj destroyedBuilding = FindDestroyedBuilding(validatedDefinitions, player.PlayerType);
                if (destroyedBuilding == null)
                {
                    DA.PagePlayer(player, $"No destroyed building found for acronym '{acronym}'.");

                    return(false);
                }

                if (!buildingFunds.TryGetValue(destroyedBuilding.ID, out BuildingFund fund) || fund.Refund(player) <= 0.0f)
                {
                    DA.PagePlayer(player, $"You haven't funded the {DATranslationManager.Translate(destroyedBuilding)}.");

                    return(false);
                }

                DA.TeamColorMessageWithTeamColor(player.PlayerType, $"{DA.MessagePrefix}{(int)(fund.TotalFunds + 0.5f)} out of {(int)(mappedDefinition.CalculateTotalRestoreCost(Engine.GetTeamPlayerCount(player.PlayerType)) + 0.5f)} credit(s) gathered to restore the {DATranslationManager.Translate(destroyedBuilding)}.");

                return(true);
            }
            else //  Assume they want all their money back
            {
                int playerCount = Engine.GetTeamPlayerCount(player.PlayerType);

                float totalRefundAmount = 0.0f;
                foreach (BuildingFund fund in buildingFunds.Values)
                {
                    float currentRefundAmount = fund.Refund(player);
                    if (currentRefundAmount > 0.0f)
                    {
                        totalRefundAmount += currentRefundAmount;

                        DA.TeamColorMessageWithTeamColor(player.PlayerType, $"{DA.MessagePrefix}{(int)(fund.TotalFunds + 0.5f)} out of {(int)(fund.MappedDefinition.CalculateTotalRestoreCost(playerCount) + 0.5f)} credit(s) gathered to restore the {DATranslationManager.Translate(fund.BuildingObj)}.");
                    }
                }

                if (totalRefundAmount <= 0.0f)
                {
                    DA.PagePlayer(player, "You haven't funded anything.");

                    return(false);
                }

                return(true);
            }
        }
Esempio n. 2
0
        public override bool VehicleEntryRequest(IScriptableGameObj obj, IcPlayer player, ref int seat)
        {
            if (player.PlayerType != DAVehicleManager.GetTeam(Owner))
            {
                return(false); //Prevent the enemy from stealing this vehicle.
            }

            return(true);
        }
Esempio n. 3
0
        private bool TotalFundChatCommand(IcPlayer player, string command, IDATokenClass text, TextMessageEnum chatType, object data)
        {
            if (!BRFEnabled)
            {
                DA.PagePlayer(player, "Building funding is not enabled for this map.");

                return(false);
            }

            string acronym = text[1];
            MappedBuildingDefinition       mappedDefinition = FindMappedDefinition(acronym);
            ICollection <IDefinitionClass> validatedDefinitions;

            if (mappedDefinition == null || (validatedDefinitions = mappedDefinition.ValidatedDefinitions) == null)
            {
                DA.PagePlayer(player, $"No building found for acronym '{acronym}'.");

                return(false);
            }

            IScriptableGameObj destroyedBuilding = FindDestroyedBuilding(validatedDefinitions, player.PlayerType);

            if (destroyedBuilding == null)
            {
                DA.PagePlayer(player, $"No destroyed building found for acronym '{acronym}'.");

                return(false);
            }

            if (mappedDefinition.RestoreCountExceeded)
            {
                DA.PagePlayer(player, $"The maximum amount of restores per map for the {DATranslationManager.Translate(destroyedBuilding)} is exceeded.");

                return(false);
            }

            if (!buildingFunds.TryGetValue(destroyedBuilding.ID, out BuildingFund fund))
            {
                fund = new BuildingFund(mappedDefinition, destroyedBuilding.ID);
                buildingFunds.Add(destroyedBuilding.ID, fund);
            }

            float totalRestoreCost = mappedDefinition.CalculateTotalRestoreCost(Engine.GetTeamPlayerCount(player.PlayerType));

            fund.NotifyPlayerContribution(player);
            DA.TeamColorMessageWithTeamColor(player.PlayerType, $"{DA.MessagePrefix}{(int)(fund.TotalFunds + 0.5f)} out of {(int)(totalRestoreCost + 0.5f)} credit(s) gathered to restore the {DATranslationManager.Translate(destroyedBuilding)}.");

            return(true);
        }
Esempio n. 4
0
        public override void CustomEvent(IScriptableGameObj obj, int type, int param, IScriptableGameObj sender)
        {
            // If a building gets restored outside of our control, we have to handle it
            if (type == (int)CustomEventType.CustomEventBuildingRevived)
            {
                if (buildingFunds.TryGetValue(Commands.GetID(obj), out BuildingFund fund))
                {
                    // If refunds are allowed, refund all players
                    if (BRFAllowRefund)
                    {
                        fund.RefundAll(); // TODO?: If a player left should we 'remember' the funds they put in the building and give them back when they rejoin later?
                    }

                    // Remove this building from the funds mapping
                    buildingFunds.Remove(fund.BuildingId);
                }
            }
        }
Esempio n. 5
0
 public override void CustomEvent(IScriptableGameObj obj, int type, int param, IScriptableGameObj sender)
 {
 }
Esempio n. 6
0
 public override void Custom(IScriptableGameObj sender, int type, int param)
 {
 }
Esempio n. 7
0
 public override void VehicleEnter(IScriptableGameObj obj, IVehicleGameObj vehicle, int seat)
 {
 }
Esempio n. 8
0
 public override bool VehicleEntryRequest(IScriptableGameObj obj, IVehicleGameObj vehicle, ref int seat)
 {
     return(true);
 }
Esempio n. 9
0
 public override void Entered(IScriptableGameObj obj, IScriptableGameObj enterer)
 {
 }
Esempio n. 10
0
 public override void AnimationComplete(IScriptableGameObj obj, string animationName)
 {
 }
Esempio n. 11
0
 public override void PowerUpGrant(IScriptableGameObj obj, IcPlayer player)
 {
 }
Esempio n. 12
0
 public override bool PowerUpGrantRequest(IScriptableGameObj obj, IPowerUpGameObjDef powerUp, IPowerUpGameObj powerUpObj)
 {
     return(true);
 }
Esempio n. 13
0
 public override bool PowerUpGrantRequest(IScriptableGameObj obj, IcPlayer player)
 {
     return(true);
 }
Esempio n. 14
0
 public override void KillReceived(IScriptableGameObj obj, IArmedGameObj killer, float damage, uint warhead, float scale, RenSharp.DADamageType type)
 {
 }
Esempio n. 15
0
 public override void KillDealt(IScriptableGameObj obj, IDamageableGameObj victim, float damage, uint warhead, float scale, RenSharp.DADamageType type)
 {
 }
Esempio n. 16
0
 public override void EnemySeen(IScriptableGameObj obj, IScriptableGameObj enemy)
 {
 }
Esempio n. 17
0
 public override void ActionComplete(IScriptableGameObj obj, int actionId, ActionCompleteReason completeReason)
 {
 }
Esempio n. 18
0
 public override void PowerUpGrant(IScriptableGameObj obj, IPowerUpGameObjDef powerUp, IPowerUpGameObj powerUpObj)
 {
 }
Esempio n. 19
0
 public override void Poked(IScriptableGameObj obj, IScriptableGameObj poker)
 {
 }
Esempio n. 20
0
 public override bool AddWeaponRequest(IScriptableGameObj obj, IWeaponDefinitionClass weapon)
 {
     return(true);
 }
Esempio n. 21
0
 public override void Exited(IScriptableGameObj obj, IScriptableGameObj exiter)
 {
 }
Esempio n. 22
0
 public override void RemoveWeapon(IScriptableGameObj obj, IWeaponClass weapon)
 {
 }
Esempio n. 23
0
 public override void VehicleEnter(IScriptableGameObj obj, IcPlayer player, int seat)
 {
 }
Esempio n. 24
0
 public override void ClearWeapons(IScriptableGameObj obj)
 {
 }
Esempio n. 25
0
 public override void ObjectCreatedEvent(IScriptableGameObj obj)
 {
     Engine.ConsoleOutput($"{nameof(ExampleEventClass)}.{nameof(ObjectCreatedEvent)}: Created object {obj.Definition}.\n");
 }
Esempio n. 26
0
 public override void Init(IScriptableGameObj obj)
 {
 }
Esempio n. 27
0
 public override void ObjectCreatedEvent(IScriptableGameObj obj)
 {
     obj.AddObserver(new RenSharpExampleObserver());
 }
Esempio n. 28
0
 public override void Destroyed(IScriptableGameObj obj)
 {
 }
Esempio n. 29
0
 public override void ObjectDestroyedEvent(IScriptableGameObj obj)
 {
 }
Esempio n. 30
0
 public override void SoundHeard(IScriptableGameObj obj, ICombatSound sound)
 {
 }