internal void TransferMoney(Entity pToEntity, uint pAmount) { uint transfer; //if CheatMoneyFactor is active for a player if (pToEntity is Player) { pAmount *= (uint)((Player)pToEntity).CheatMoneyFactor; } if (this is Player) { pAmount = (uint)(pAmount / ((Player)this).CheatMoneyFactor); } if (pAmount > 0) { //Entity doesn't need cash check if (this.GetType() == typeof(Entity)) { transfer = pAmount; pToEntity.Cash += (int)transfer; Cash -= (int)transfer; MoneyTransfered?.Invoke(this, pToEntity, pAmount); } //to less cash -> bankcrupt else if (pAmount > _CreditLimit + Cash) { if (Cash < 0) { transfer = (uint)(_CreditLimit - Cash); } else { transfer = (uint)(_CreditLimit + Cash); } pToEntity.Cash += (int)transfer; Cash -= (int)transfer; MoneyTransfered?.Invoke(this, pToEntity, System.Convert.ToUInt32(transfer)); (this as Player).OnBankrupt(); } //rest should be fine else { transfer = pAmount; pToEntity.Cash += (int)transfer; Cash -= (int)transfer; MoneyTransfered?.Invoke(this, pToEntity, System.Convert.ToUInt32(transfer)); } } else { throw new DotNetPolyException("negative cash transfer!"); } }
public void Apply(MoneyTransfered successfulTransfer) { }