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); } }
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); }
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); }
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); } } }
public override void CustomEvent(IScriptableGameObj obj, int type, int param, IScriptableGameObj sender) { }
public override void Custom(IScriptableGameObj sender, int type, int param) { }
public override void VehicleEnter(IScriptableGameObj obj, IVehicleGameObj vehicle, int seat) { }
public override bool VehicleEntryRequest(IScriptableGameObj obj, IVehicleGameObj vehicle, ref int seat) { return(true); }
public override void Entered(IScriptableGameObj obj, IScriptableGameObj enterer) { }
public override void AnimationComplete(IScriptableGameObj obj, string animationName) { }
public override void PowerUpGrant(IScriptableGameObj obj, IcPlayer player) { }
public override bool PowerUpGrantRequest(IScriptableGameObj obj, IPowerUpGameObjDef powerUp, IPowerUpGameObj powerUpObj) { return(true); }
public override bool PowerUpGrantRequest(IScriptableGameObj obj, IcPlayer player) { return(true); }
public override void KillReceived(IScriptableGameObj obj, IArmedGameObj killer, float damage, uint warhead, float scale, RenSharp.DADamageType type) { }
public override void KillDealt(IScriptableGameObj obj, IDamageableGameObj victim, float damage, uint warhead, float scale, RenSharp.DADamageType type) { }
public override void EnemySeen(IScriptableGameObj obj, IScriptableGameObj enemy) { }
public override void ActionComplete(IScriptableGameObj obj, int actionId, ActionCompleteReason completeReason) { }
public override void PowerUpGrant(IScriptableGameObj obj, IPowerUpGameObjDef powerUp, IPowerUpGameObj powerUpObj) { }
public override void Poked(IScriptableGameObj obj, IScriptableGameObj poker) { }
public override bool AddWeaponRequest(IScriptableGameObj obj, IWeaponDefinitionClass weapon) { return(true); }
public override void Exited(IScriptableGameObj obj, IScriptableGameObj exiter) { }
public override void RemoveWeapon(IScriptableGameObj obj, IWeaponClass weapon) { }
public override void VehicleEnter(IScriptableGameObj obj, IcPlayer player, int seat) { }
public override void ClearWeapons(IScriptableGameObj obj) { }
public override void ObjectCreatedEvent(IScriptableGameObj obj) { Engine.ConsoleOutput($"{nameof(ExampleEventClass)}.{nameof(ObjectCreatedEvent)}: Created object {obj.Definition}.\n"); }
public override void Init(IScriptableGameObj obj) { }
public override void ObjectCreatedEvent(IScriptableGameObj obj) { obj.AddObserver(new RenSharpExampleObserver()); }
public override void Destroyed(IScriptableGameObj obj) { }
public override void ObjectDestroyedEvent(IScriptableGameObj obj) { }
public override void SoundHeard(IScriptableGameObj obj, ICombatSound sound) { }