/// <summary> /// Ticks for update this instance. /// </summary> public void Tick() { if (this.GetRemainingBoostTimeSecs() > 0) { if (this._timer != null) { if (!this.IsBoostPaused()) { this._timer.FastForwardSubticks(4 * this.GetBoostMultiplier() - 4); } } } Boolean prodCompleted = this._timer != null && this._timer.GetRemainingSeconds(this._level.GetLogicTime()) == 0; LogicCombatItemData prodData = this.GetWaitingForSpaceUnit(); if (this._nextProduction > 0) { this._nextProduction = prodCompleted ? 0 : LogicMath.Max(this._nextProduction - 64, 0); } if (this._boostTimer != null && this._boostTimer.GetRemainingSeconds(this._level.GetLogicTime()) <= 0) { this._boostTimer.Destruct(); this._boostTimer = null; } if (prodCompleted || prodData != null) { if (this._nextProduction == 0) { this.ProductionCompleted(false); } } }
/// <summary> /// Gets the max spell forge level. /// </summary> public int GetMaxSpellForgeLevel() { LogicArrayList <LogicComponent> components = this._components[3]; if (components.Count > 0) { int maxUpgLevel = -1; int idx = 0; do { LogicUnitProductionComponent component = (LogicUnitProductionComponent)components[idx]; if (component.GetProductionType() != 0) { if (component.GetParent().GetGameObjectType() == 0) { LogicBuilding parent = (LogicBuilding)component.GetParent(); if (parent.GetBuildingData().GetProducesUnitsOfType() == 1 && (!parent.IsConstructing() || parent.IsUpgrading())) { maxUpgLevel = LogicMath.Max(parent.GetUpgradeLevel(), maxUpgLevel); } } } } while (++idx != components.Count); return(maxUpgLevel); } return(-1); }
/// <summary> /// Ticks for update this component. /// </summary> public override void Tick() { if (this._regenerationEnabled) { if (this._hp < this._maxHp) { if (this._maxRegenerationTime <= 0) { this._hp = this._maxHp; } else { this._regenTime += 64; int tmp = LogicMath.Max(1000 * this._regenTime / (this._maxHp / 100), 1); this._hp = this._hp + 100 * (this._regenTime / tmp); if (this._hp > this._maxHp) { this._hp = this._maxHp; this._regenTime = 0; } else { this._regenTime %= tmp; } } } } this._lastDamageTime += 1; }
public override void ResourcesStolen(int damage, int hp) { if (damage > 0 && hp > 0) { LogicDataTable table = LogicDataTables.GetTable(LogicDataType.RESOURCE); for (int i = 0; i < this.m_stealableResourceCount.Size(); i++) { LogicResourceData data = (LogicResourceData)table.GetItemAt(i); int stealableResource = this.GetStealableResourceCount(i); if (damage < hp) { stealableResource = damage * stealableResource / hp; } if (stealableResource > 0 && data.GetWarResourceReferenceData() != null) { this.m_parent.GetLevel().GetBattleLog().IncreaseStolenResourceCount(data.GetWarResourceReferenceData(), stealableResource); this.m_resourceCount[i] -= stealableResource; LogicAvatar homeOwnerAvatar = this.m_parent.GetLevel().GetHomeOwnerAvatar(); LogicAvatar visitorAvatar = this.m_parent.GetLevel().GetVisitorAvatar(); homeOwnerAvatar.CommodityCountChangeHelper(0, data, -stealableResource); visitorAvatar.CommodityCountChangeHelper(0, data.GetWarResourceReferenceData(), stealableResource); this.m_stealableResourceCount[i] = LogicMath.Max(this.m_stealableResourceCount[i] - stealableResource, 0); } } } }
public static int CalculateNewRating(bool gain, int attackerScore, int defenderScore, int multiplier, int eloOffsetDampeningFactor, int eloOffsetDampeningLimit, int eloOffsetDampeningScoreLimit) { int diffScore = defenderScore - attackerScore; if (eloOffsetDampeningFactor > 0 && eloOffsetDampeningLimit > 0 && eloOffsetDampeningScoreLimit > 0) { diffScore = diffScore * LogicMath.Max(eloOffsetDampeningLimit, 100 - eloOffsetDampeningFactor * (attackerScore + defenderScore) / eloOffsetDampeningScoreLimit) / 100; } int winChanceOffset = 0; if (diffScore >= -1000) { winChanceOffset = diffScore + 1000; if (diffScore > 1000) { winChanceOffset = 2000; } } return(attackerScore + multiplier * ((gain ? 10000 : 0) - LogicELOMath.WIN_CHANGE_TABLE[winChanceOffset]) / 10000); }
public override void ApplyAvatarChange(LogicClientAvatar avatar) { avatar.SetScore(LogicMath.Max(avatar.GetScore() + this.ScoreGain, 0)); avatar.SetLeagueType(this.LeagueData.GetInstanceID()); if (this.PrevLeagueData != null) { if (this.Attacker) { if (this.ScoreGain < 0) { avatar.SetAttackLoseCount(avatar.GetAttackLoseCount() + 1); } else { avatar.SetAttackWinCount(avatar.GetAttackWinCount() + 1); } } else { if (this.ScoreGain < 0) { avatar.SetDefenseLoseCount(avatar.GetDefenseLoseCount() + 1); } else { avatar.SetDefenseWinCount(avatar.GetDefenseWinCount() + 1); } } } }
public int GetMaxMiniSpellForgeLevel() { LogicArrayList <LogicComponent> components = this.m_components[(int)LogicComponentType.UNIT_PRODUCTION]; if (components.Size() > 0) { int maxUpgLevel = -1; int idx = 0; do { LogicUnitProductionComponent component = (LogicUnitProductionComponent)components[idx]; if (component.GetProductionType() != 0) { if (component.GetParent().GetGameObjectType() == LogicGameObjectType.BUILDING) { LogicBuilding parent = (LogicBuilding)component.GetParent(); if (parent.GetBuildingData().GetProducesUnitsOfType() == 2 && (!parent.IsConstructing() || parent.IsUpgrading())) { maxUpgLevel = LogicMath.Max(parent.GetUpgradeLevel(), maxUpgLevel); } } } } while (++idx != components.Size()); return(maxUpgLevel); } return(-1); }
/// <summary> /// Ticks this instance. /// </summary> public override void Tick() { base.Tick(); if (this._constructionTimer != null) { if (this._level.GetRemainingClockTowerBoostTime() > 0 && this._data.GetVillageType() == 1) { this._constructionTimer.SetFastForward(this._constructionTimer.GetFastForward() + 4 * LogicDataTables.GetGlobals().GetClockTowerBoostMultiplier() - 4); } if (this._constructionTimer.GetRemainingSeconds(this._level.GetLogicTime()) <= 0) { this.FinishConstruction(false); } } if (this._disarmed) { if (this._fadeTime >= 0) { this._fadeTime = LogicMath.Max(this._fadeTime + 64, 1000); } } }
public static int GetStartupCooldownSeconds() { if (ServerStatus.Status == ServerStatusType.COOLDOWN_AFTER_MAINTENANCE) { return(LogicMath.Max(ServerStatus.Time - TimeUtil.GetTimestamp(), 0)); } return(0); }
public bool TrainingFinished() { bool success = false; if (this.m_timer != null) { this.m_timer.Destruct(); this.m_timer = null; } if (this.m_slots.Size() > 0) { LogicUnitProductionSlot prodSlot = this.GetCurrentlyTrainedSlot(); int prodIdx = this.GetCurrentlyTrainedIndex(); if (prodSlot != null) { if (prodSlot.GetCount() == 1) { prodSlot.SetTerminate(true); } else { prodSlot.SetCount(prodSlot.GetCount() - 1); LogicUnitProductionSlot previousSlot = this.m_slots[LogicMath.Max(prodIdx - 1, 0)]; if (previousSlot != null && previousSlot.IsTerminate() && previousSlot.GetData().GetGlobalID() == prodSlot.GetData().GetGlobalID()) { previousSlot.SetCount(previousSlot.GetCount() + 1); } else { this.m_slots.Add(prodIdx, new LogicUnitProductionSlot(prodSlot.GetData(), 1, true)); } } } if (this.m_slots.Size() > 0) { LogicCombatItemData nextProductionData = this.GetCurrentlyTrainedUnit(); if (nextProductionData != null && this.m_timer == null) { this.m_timer = new LogicTimer(); this.m_timer.StartTimer(nextProductionData.GetTrainingTime(this.m_level.GetHomeOwnerAvatar().GetUnitUpgradeLevel(nextProductionData), this.m_level, 0), this.m_level.GetLogicTime(), false, -1); success = true; } } } this.MergeSlots(); return(success); }
public void StartUseTroopEvent(LogicAvatar homeOwnerAvatar, LogicLevel level) { if (homeOwnerAvatar != null) { for (int i = 0; i < this.m_useTroops.Size(); i++) { LogicCalendarUseTroop calendarUseTroop = this.m_useTroops[i]; LogicCombatItemData data = calendarUseTroop.GetData(); int housingSpace; int totalMaxHousing; int unitCount; if (data.GetCombatItemType() != LogicCombatItemData.COMBAT_ITEM_TYPE_CHARACTER) { housingSpace = data.GetHousingSpace() * 2; totalMaxHousing = data.GetHousingSpace() + 2 * (level.GetComponentManagerAt(data.GetVillageType()).GetTotalMaxHousing(data.GetCombatItemType()) * calendarUseTroop.GetParameter(1) / 100); unitCount = totalMaxHousing / housingSpace; } else { LogicBuildingData troopHousingData = LogicDataTables.GetBuildingByName("Troop Housing", null); LogicBuildingData barrackData = LogicDataTables.GetBuildingByName("Barrack", null); LogicBuildingData darkElixirBarrackData = LogicDataTables.GetBuildingByName("Dark Elixir Barrack", null); int townHallLevel = homeOwnerAvatar.GetTownHallLevel(); int maxUpgradeLevelForTH = troopHousingData.GetMaxUpgradeLevelForTownHallLevel(townHallLevel); int unitStorageCapacity = troopHousingData.GetUnitStorageCapacity(maxUpgradeLevelForTH); housingSpace = data.GetHousingSpace(); if (data.GetUnitOfType() == 1 && barrackData.GetRequiredTownHallLevel(data.GetRequiredProductionHouseLevel()) <= townHallLevel || data.GetUnitOfType() == 2 && darkElixirBarrackData.GetRequiredTownHallLevel(data.GetRequiredProductionHouseLevel()) <= townHallLevel) { int totalHousing = (int)((long)LogicDataTables.GetTownHallLevel(townHallLevel).GetUnlockedBuildingCount(troopHousingData) * calendarUseTroop.GetParameter(1) * unitStorageCapacity); unitCount = (int)((housingSpace * 0.5f + totalHousing / 100) / housingSpace); } else { LogicBuildingData allianceCastleData = LogicDataTables.GetBuildingByName("Alliance Castle", null); totalMaxHousing = allianceCastleData.GetUnitStorageCapacity(allianceCastleData.GetMaxUpgradeLevelForTownHallLevel(townHallLevel)); unitCount = totalMaxHousing / housingSpace; } } int eventCounter = LogicMath.Max(1, unitCount) << 16; homeOwnerAvatar.SetCommodityCount(6, data, eventCounter); homeOwnerAvatar.GetChangeListener().CommodityCountChanged(6, data, eventCounter); Debugger.HudPrint("EVENT: Use troop/spell event started!"); } } }
public static int GetRadius(int x, int y) { x = LogicMath.Abs(x); y = LogicMath.Abs(y); int maxValue = LogicMath.Max(x, y); int minValue = LogicMath.Min(x, y); return(maxValue + (53 * minValue >> 7)); }
public int GetAmmoCost(int index, int count) { if (count < 1) { return(0); } return(LogicMath.Max(this.m_ammoCost[index] * count / this.m_attackItemData[index].GetAmmoCount(), 1)); }
/// <summary> /// Gets the remaining guard time. /// </summary> public int GetGuardRemainingSeconds() { int startTime = this._startGuardTime - this._level.GetLogicTime(); if (startTime <= 0) { startTime = 0; } return(LogicMath.Max(LogicTime.GetTicksInSeconds(this._guardTime + startTime), 0)); }
public int GetBiggestArraySize() { int columnCount = this.m_table.GetColumnCount(); int maxSize = 1; for (int i = columnCount - 1; i >= 0; i--) { maxSize = LogicMath.Max(this.m_table.GetArraySizeAt(this, i), maxSize); } return(maxSize); }
internal override void Execute() { var cost = 0; if (LogicMath.Max(0, 0) >= 1) { } this.Connection.Avatar.Diamonds -= cost; this.Connection.Avatar.Sailing.Finish(); this.Connection.Avatar.Save(); }
private static void OnServerStatusChanged(ServerStatusType type, int time, int args) { switch (type) { case ServerStatusType.SHUTDOWN_STARTED: ClientConnectionManager.SendShutdownStartedMessageToConnections(LogicMath.Max(time - TimeUtil.GetTimestamp(), 0)); break; case ServerStatusType.MAINTENANCE: ClientConnectionManager.DisconnectConnections(); break; } }
public void RefreshSubTiles() { this.m_passableFlag &= 0xF0; this.m_pathFinderCost = 0; for (int i = 0; i < this.m_gameObjects.Size(); i++) { LogicGameObject gameObject = this.m_gameObjects[i]; this.m_pathFinderCost = LogicMath.Max(this.m_pathFinderCost, gameObject.PathFinderCost()); if (!gameObject.IsPassable()) { int width = gameObject.GetWidthInTiles(); int height = gameObject.GetWidthInTiles(); if (width == 1 || height == 1) { this.m_passableFlag |= 0xF; } else { int edge = gameObject.PassableSubtilesAtEdge(); int startX = 2 * (this.m_tileX - gameObject.GetTileX()); int startY = 2 * (this.m_tileY - gameObject.GetTileY()); int endX = 2 * width - edge; int endY = 2 * height - edge; for (int j = 0; j < 2; j++) { int offset = j; int x = startX + j; for (int k = 0; k < 2; k++) { int y = startY + k; if (y < endY && x < endX && x >= edge && y >= edge) { this.m_passableFlag |= (byte)(1 << offset); } offset += 2; } } } } } }
public void UpdatePushBack() { int startSpeed = this.m_pushTime * this.m_pushTime / this.m_pushInitTime; int endSpeed = this.m_pushInitTime - startSpeed; int pushBackX = (startSpeed * this.m_pushBackStartPosition.m_x + endSpeed * this.m_pushBackEndPosition.m_x) / this.m_pushInitTime; int pushBackY = (startSpeed * this.m_pushBackStartPosition.m_y + endSpeed * this.m_pushBackEndPosition.m_y) / this.m_pushInitTime; if (this.m_parent == null || this.m_parent.IsFlying() || this.m_parent.GetParent().GetLevel().GetTileMap().IsPassablePathFinder(pushBackX >> 8, pushBackY >> 8) || this.m_ignorePush) { this.SetPosition(pushBackX, pushBackY); } else { this.m_pushBackStartPosition.m_x = this.m_position.m_x; this.m_pushBackStartPosition.m_y = this.m_position.m_y; this.m_pushBackEndPosition.m_x = this.m_position.m_x; this.m_pushBackEndPosition.m_y = this.m_position.m_y; } this.m_pushTime = LogicMath.Max(this.m_pushTime - 16, 0); if (this.m_pushTime == 0) { LogicGameObject parent = this.m_parent.GetParent(); LogicCombatComponent combatComponent = parent.GetCombatComponent(); if (parent.GetGameObjectType() == LogicGameObjectType.CHARACTER) { LogicCharacter character = (LogicCharacter)parent; if (character.GetCharacterData().GetPickNewTargetAfterPushback() || this.m_ignorePush) { if (combatComponent != null) { combatComponent.ForceNewTarget(); } } } this.m_parent.NewTargetFound(); if (combatComponent != null) { combatComponent.StopAttack(); } this.m_ignorePush = false; } }
/// <summary> /// Gets the remaining ban time. /// </summary> internal int GetRemainingBanTime() { if (this.CurrentBan != null) { if (this.CurrentBan.EndBanTime != -1) { return(LogicMath.Max(LogicTimeUtil.GetTimestamp() - this.CurrentBan.EndBanTime, 0)); } return(-1); } return(0); }
public int GetHeroHitpoints(int hp, int upgLevel) { hp = LogicMath.Max(0, hp); int regenTime = this.m_regenerationTimeSecs[upgLevel]; int hitpoints = this.m_hitpoints[upgLevel]; if (regenTime != 0) { hitpoints = hitpoints * (LogicMath.Max(regenTime - hp, 0) / 60) / (regenTime / 60); } return(hitpoints); }
public void Boost(int speed, int time) { if (speed < 0) { this.m_slowSpeed = LogicMath.Min(LogicMath.Max(-100, speed), this.m_slowSpeed); this.m_slowTime = time; } else { int idx = this.m_boostSpeed[0] != 0 ? 1 : 0; this.m_boostSpeed[idx] = LogicMath.Max(speed, this.m_boostSpeed[idx]); this.m_boostTime[idx] = time; } }
/// <summary> /// Trains the unit with new training. /// </summary> public int NewTrainingUnit(LogicLevel level) { if (LogicDataTables.GetGlobals().UseNewTraining()) { if (this._unitData != null) { LogicUnitProduction unitProduction = this._unitData.GetCombatItemType() == 1 ? level.GetGameObjectManager().GetSpellProduction() : level.GetGameObjectManager().GetUnitProduction(); if (!unitProduction.IsLocked()) { if (this._unitCount > 0) { if (this._unitData.GetDataType() == unitProduction.GetUnitProductionType()) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); LogicResourceData trainingResourceData = this._unitData.GetTrainingResource(); Int32 trainingCost = level.GetGameMode().GetCalendar().GetUnitTrainingCost(this._unitData, playerAvatar.GetUnitUpgradeLevel(this._unitData)); Int32 refundCount = LogicMath.Max(trainingCost * (this._unitData.GetDataType() != 3 ? LogicDataTables.GetGlobals().GetSpellCancelMultiplier() : LogicDataTables.GetGlobals().GetTrainCancelMultiplier()) / 100, 0); while (unitProduction.RemoveUnit(this._unitData, this._slotId)) { playerAvatar.CommodityCountChangeHelper(0, trainingResourceData, refundCount); if (--this._unitCount <= 0) { break; } } return(0); } } return(-1); } return(-23); } return(-1); } return(-99); }
public override int Execute(LogicLevel level) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar != null) { int lootLimitCooldown = playerAvatar.GetVariableByName("LootLimitCooldown"); if (lootLimitCooldown == 1) { LogicConfiguration configuration = level.GetGameMode().GetConfiguration(); if (configuration != null) { LogicCalendar calendar = level.GetGameMode().GetCalendar(); if (calendar != null) { int remainingSecs = playerAvatar.GetRemainingLootLimitTime(); int totalSecs = LogicCalendar.GetDuelLootLimitCooldownInMinutes(calendar, configuration) * 60; int maxDiamondsCostPercent = LogicCalendar.GetDuelBonusMaxDiamondCostPercent(calendar, configuration); int speedUpCost = LogicMath.Max( LogicGamePlayUtil.GetLeagueVillage2(playerAvatar.GetDuelScore()).GetMaxDiamondCost() * maxDiamondsCostPercent * remainingSecs / totalSecs / 100, 1); if (playerAvatar.HasEnoughDiamonds(speedUpCost, true, level)) { playerAvatar.UseDiamonds(speedUpCost); playerAvatar.GetChangeListener().DiamondPurchaseMade(18, 0, remainingSecs, speedUpCost, level.GetVillageType()); playerAvatar.FastForwardLootLimit(remainingSecs); return(0); } return(-3); } return(-5); } return(-4); } return(-3); } return(-2); }
public virtual void ResourcesStolen(int damage, int hp) { if (damage > 0 && hp > 0) { LogicDataTable table = LogicDataTables.GetTable(LogicDataType.RESOURCE); for (int i = 0; i < this.m_stealableResourceCount.Size(); i++) { LogicResourceData data = (LogicResourceData)table.GetItemAt(i); int stealableResource = this.GetStealableResourceCount(i); if (damage < hp) { stealableResource = damage * stealableResource / hp; } if (stealableResource > 0) { this.m_parent.GetLevel().GetBattleLog().IncreaseStolenResourceCount(data, stealableResource); this.m_resourceCount[i] -= stealableResource; LogicAvatar homeOwnerAvatar = this.m_parent.GetLevel().GetHomeOwnerAvatar(); LogicAvatar visitorAvatar = this.m_parent.GetLevel().GetVisitorAvatar(); homeOwnerAvatar.CommodityCountChangeHelper(0, data, -stealableResource); visitorAvatar.CommodityCountChangeHelper(0, data, stealableResource); if (homeOwnerAvatar.IsNpcAvatar()) { LogicNpcData npcData = ((LogicNpcAvatar)homeOwnerAvatar).GetNpcData(); if (data == LogicDataTables.GetGoldData()) { visitorAvatar.CommodityCountChangeHelper(1, npcData, stealableResource); } else if (data == LogicDataTables.GetElixirData()) { visitorAvatar.CommodityCountChangeHelper(2, npcData, stealableResource); } } this.m_stealableResourceCount[i] = LogicMath.Max(this.m_stealableResourceCount[i] - stealableResource, 0); } } } }
/// <summary> /// Gets the remaining attack seconds. /// </summary> public int GetRemainingAttackSeconds() { if ((this._state == 2 || this._state == 5) && !this._battleOver) { if (!this._level.InvulnerabilityEnabled()) { if (this._battleTimer != null) { return(LogicMath.Max(this._battleTimer.GetRemainingSeconds(this._level.GetLogicTime()), 1)); } } return(1); } return(0); }
public override void FastForwardTime(int secs) { LogicArrayList <LogicComponent> components = this.m_parent.GetComponentManager().GetComponents(LogicComponentType.VILLAGE2_UNIT); int barrackCount = this.m_parent.GetGameObjectManager().GetBarrackCount(); int barrackFoundCount = 0; for (int i = 0; i < barrackCount; i++) { LogicBuilding building = (LogicBuilding)this.m_parent.GetGameObjectManager().GetBarrack(i); if (building != null && !building.IsConstructing()) { barrackFoundCount += 1; } } if (components.Size() <= 0 || barrackFoundCount != 0 && components[0] == this) { LogicLevel level = this.m_parent.GetLevel(); int clockTowerBoostTime = level.GetUpdatedClockTowerBoostTime(); int boostTime = 0; if (clockTowerBoostTime > 0 && !level.IsClockTowerBoostPaused()) { LogicGameObjectData data = this.m_parent.GetData(); if (data.GetDataType() == LogicDataType.BUILDING) { if (data.GetVillageType() == 1) { boostTime = LogicMath.Min(secs, clockTowerBoostTime) * (LogicDataTables.GetGlobals().GetClockTowerBoostMultiplier() - 1); } } } int remainingSecs = secs + boostTime; for (int i = 0; i < components.Size(); i++) { remainingSecs = LogicMath.Max(0, remainingSecs - ((LogicVillage2UnitComponent)components[i]).FastForwardProduction(remainingSecs)); } } }
public void DivideAvatarResourcesToStorages() { LogicAvatar homeOwnerAvatar = this.m_level.GetHomeOwnerAvatar(); if (homeOwnerAvatar != null) { LogicArrayList <LogicComponent> resourceStorageComponents = this.m_components[(int)LogicComponentType.RESOURCE_STORAGE]; LogicArrayList <LogicComponent> warResourceStorageComponents = this.m_components[(int)LogicComponentType.WAR_RESOURCE_STORAGE]; LogicDataTable resourceTable = LogicDataTables.GetTable(LogicDataType.RESOURCE); for (int i = 0; i < resourceTable.GetItemCount(); i++) { LogicResourceData data = (LogicResourceData)resourceTable.GetItemAt(i); if (!data.IsPremiumCurrency()) { if (data.GetWarResourceReferenceData() != null) { Debugger.DoAssert(warResourceStorageComponents.Size() < 2, "Too many war storage components"); for (int j = 0; j < warResourceStorageComponents.Size(); j++) { LogicWarResourceStorageComponent warResourceStorageComponent = (LogicWarResourceStorageComponent)warResourceStorageComponents[j]; warResourceStorageComponent.SetCount(i, homeOwnerAvatar.GetResourceCount(data)); } } else { for (int j = 0; j < resourceStorageComponents.Size(); j++) { ((LogicResourceStorageComponent)resourceStorageComponents[j]).SetCount(i, 0); } int resourceCount = homeOwnerAvatar.GetResourceCount(data); if (this.m_level.GetBattleLog() != null && data.GetVillageType() == 1) { resourceCount = LogicMath.Max(resourceCount - this.m_level.GetBattleLog().GetCostCount(data), 0); } this.AddResources(i, resourceCount, true); } } } } }
public void Freeze(int time, int delay) { if (this.m_freezeTime > 0 && this.m_freezeDelay == 0) { this.m_freezeTime = LogicMath.Max(time - delay, this.m_freezeTime); } else if (this.m_freezeDelay > 0) { this.m_freezeDelay = LogicMath.Max(delay, this.m_freezeDelay); this.m_freezeTime = LogicMath.Max(time, this.m_freezeTime); } else { this.m_freezeTime = time; this.m_freezeDelay = delay; } }
/// <summary> /// Loads all accounts from database. /// </summary> internal static void LoadAccounts() { int dbCount = DatabaseManager.GetDatabaseCount(0); for (int i = 0; i < dbCount; i++) { CouchbaseDatabase database = DatabaseManager.GetDatabaseAt(0, i); if (database != null) { int highId = i; int maxLowId = database.GetHigherId(); object locker = new object(); Parallel.For(1, maxLowId + 1, new ParallelOptions { MaxDegreeOfParallelism = 4 }, id => { LogicLong accId = new LogicLong(highId, id); if (NetManager.GetDocumentOwnerId(ServiceCore.ServiceNodeType, id) == ServiceCore.ServiceNodeId) { string json = database.GetDocument(accId); if (json != null) { Account account = new Account(); account.Load(json); lock (locker) { AccountManager._accounts.Add(account.Id, account); AccountManager._accountCounters[highId] = LogicMath.Max(id, AccountManager._accountCounters[highId]); } } } }); } else { Logging.Warning("AccountManager::loadAccounts pDatabase->NULL"); } } }