public void RegisterEvent(StaticString key, TransitionEventDelegate d) { try { m_DelegateMap[key.ToString()] += d.Invoke; } catch (KeyNotFoundException) { m_DelegateMap.Add(key.ToString(), d.Invoke); } }
public object GetLobbyData(StaticString key) { object result; if (this.lobbyData.TryGetValue(key, out result)) { return(result); } if (this.lobbyData.TryGetValue(key.ToString().ToLower(), out result)) { return(result); } return(null); }
public bool GetAchievement(StaticString achievementName) { if (this.IsDisabled) { return(false); } if (this.achievements == null && !StaticString.IsNullOrEmpty(achievementName)) { Diagnostics.LogWarning("Setting network achievement '{0}' before it has been received.", new object[] { achievementName.ToString() }); return(false); } if (!this.achievements.Contains(achievementName)) { Diagnostics.LogWarning("Can't find network achievement '{0}'.", new object[] { achievementName.ToString() }); return(false); } return(this.GetNetworkAchievement(achievementName)); }
public void AddDistrict(District district) { if (district == null) { throw new ArgumentNullException("district"); } if (!district.GUID.IsValid) { Diagnostics.LogError("Cannot add district with invalid guid."); return; } if (this.districts.Exists((District item) => item.GUID == district.GUID)) { Diagnostics.Assert(district.City == this); Diagnostics.LogWarning("Cannot add district twice to the same city, ignoring..."); return; } if (district.City != null) { Diagnostics.Assert(district.City != this); Diagnostics.LogWarning("Cannot add district already linked to another city, ignoring..."); return; } this.districts.Add(district); district.City = this; base.AddChild(district); if (district.Type != DistrictType.Exploitation) { this.ExtensionCount++; } if (this.DryDockPosition == WorldPosition.Invalid) { IWorldPositionningService service = this.gameService.Game.Services.GetService <IWorldPositionningService>(); if (service.IsWaterTile(district.WorldPosition) && !service.IsFrozenWaterTile(district.WorldPosition)) { GridMap <byte> map = (this.gameService.Game as global::Game).World.Atlas.GetMap(WorldAtlas.Maps.Terrain) as GridMap <byte>; Map <TerrainTypeName> map2 = (this.gameService.Game as global::Game).World.Atlas.GetMap(WorldAtlas.Tables.Terrains) as Map <TerrainTypeName>; byte value = map.GetValue(district.WorldPosition); StaticString empty = StaticString.Empty; if (map2.Data.TryGetValue((int)value, ref empty) && empty.ToString().IndexOf("InlandWater") == -1) { this.DryDockPosition = district.WorldPosition; } } } this.OnCityDistrictCollectionChange(CollectionChangeAction.Add, district); }
public override void SetLobbyData(StaticString key, object data, bool replicate = true) { if (base.IsHosting && !replicate && !key.ToString().StartsWith("__")) { object obj; if (this.lobbyData.TryGetValue(key, out obj) && data != null && obj.ToString() != data.ToString()) { base.SteamMatchMakingService.SteamMatchMaking.SetLobbyData(base.SteamIDLobby, key, obj.ToString()); Diagnostics.Log("[ELQC-2566] Fixed Lobby Data'{0}' = '{1}' instead of '{2}'.", new object[] { key, obj.ToString(), data.ToString() }); } return; } base.SetLobbyData(key, data, replicate); }
private void CacheAttitudeMultipliers() { IPersonalityAIHelper service = AIScheduler.Services.GetService <IPersonalityAIHelper>(); Diagnostics.Assert(service != null); this.attitudeMultipliers = new Dictionary <StaticString, float>(); string arg = string.Format("AI/AgentDefinition/{0}", base.GetType().Name); for (int i = 0; i < AILayer_Attitude.AttitudeScoreDefinitionReferences.All.Length; i++) { StaticString staticString = AILayer_Attitude.AttitudeScoreDefinitionReferences.All[i]; string regitryPath = string.Format("{0}/{1}{2}", arg, staticString.ToString().Substring("AttitudeScore".Length), "Multiplier"); float registryValue = service.GetRegistryValue <float>(this.Empire, regitryPath, 0f); if (registryValue != 0f) { this.attitudeMultipliers[staticString] = registryValue; } } }
public static ATransitionConditional <TOwner> AllocateAndAttachEventConditional(StaticString behaviorName, StaticString name, ref TransitionEventDelegate delegateInst, Type delegateType) { string behaviorQualifiedName = TransitionConditionalLibrary.Instance.FindAssemblyQualifiedName(behaviorName.ToString(), delegateType.GetGenericArguments().Length + 1); ATransitionConditional <TOwner> behavior = AllocateEventConditional(behaviorQualifiedName, name, delegateType); object[] argArray = new object[] { delegateInst }; try { Type t = behavior.GetType(); t.InvokeMember("AttachHandler", BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, null, behavior, argArray); } catch (Exception e) { Log.Error("User Caught Exception(t.InvokeMember): " + e.Message); } delegateInst = argArray[0] as TransitionEventDelegate; return(behavior); }
public override void RefreshContent() { base.RefreshContent(); float propertyValue = this.City.GetPropertyValue(SimulationProperties.NetCityApproval); this.ApprovalGauge.PercentRight = Mathf.Clamp(propertyValue, 0f, 100f); this.ApprovalValue.Text = GuiFormater.FormatGui(propertyValue * 0.01f, true, false, false, 1); StaticString descriptorNameFromType = this.City.GetDescriptorNameFromType("ApprovalStatus"); GuiElement guiElement; if (base.GuiService.GuiPanelHelper.TryGetGuiElement(descriptorNameFromType, out guiElement, this.City.Empire.Faction.Name)) { this.ApprovalState.Text = guiElement.Title; ExtendedGuiElement extendedGuiElement = guiElement as ExtendedGuiElement; if (extendedGuiElement != null) { this.ApprovalGauge.AgePrimitive.TintColor = extendedGuiElement.Color; this.ApprovalState.TintColor = extendedGuiElement.Color; } } else { this.ApprovalState.Text = "%ApprovalStatusUnknown"; } if (this.ApprovalState.AgeTransform.AgeTooltip != null) { this.ApprovalState.AgeTransform.AgeTooltip.Content = descriptorNameFromType.ToString(); } this.RefreshPopulationCount(); this.RefreshPopulationGrowth(); int num = Mathf.CeilToInt(this.City.GetPropertyValue(SimulationProperties.CityMoneyUpkeep)); this.UpkeepValue.Text = GuiFormater.FormatQuantity((float)(-(float)num), SimulationProperties.CityMoneyUpkeep, 1); AgeTooltip ageTooltip = this.UpkeepValue.AgeTransform.AgeTooltip; ageTooltip.Content = string.Format(AgeLocalizer.Instance.LocalizeString("%BuildingsUpkeepFormatDescription"), this.UpkeepValue.Text); this.UpkeepIcon1.AgeTooltip.Copy(ageTooltip); this.UpkeepIcon2.AgeTooltip.Copy(ageTooltip); for (int i = 0; i < this.typesFIDS.Count; i++) { if (i < this.valuesFIDS.Count && i < this.deltaFIDS.Count) { if (!this.valuesFIDS[i].AgeTransform.ModifiersRunning) { this.valuesFIDS[i].AgeTransform.Alpha = 1f; this.valuesFIDS[i].AgeTransform.ResetAllModifiers(true, false); this.deltaFIDS[i].AgeTransform.Alpha = 0f; this.deltaFIDS[i].AgeTransform.ResetAllModifiers(true, false); } float propertyValue2 = this.City.GetPropertyValue(this.typesFIDS[i]); this.valuesFIDS[i].Text = GuiFormater.FormatGui(propertyValue2, false, false, false, 0); if (propertyValue2 != this.previousFIDS[i]) { this.AnimateFIDSChange(this.valuesFIDS[i], this.deltaFIDS[i], propertyValue2 - this.previousFIDS[i]); this.previousFIDS[i] = propertyValue2; } } } for (int j = 0; j < this.workerTypes.Count; j++) { if (j < this.workersFIDS.Count) { this.workersFIDS[j].Text = this.City.GetPropertyValue(this.workerTypes[j]).ToString(); } } if (this.CityWorkersPanel.IsVisible) { this.CityWorkersPanel.RefreshContent(); } this.RefreshButtons(); }