public void SetActiveResearch(Tech tech, bool clearQueue = false) { if (clearQueue) { queuedTech.Clear(); } activeResearch = null; if (tech != null) { if (queuedTech.Count == 0) { AddTechToQueue(tech); } if (queuedTech.Count > 0) { queuedTech.Sort((TechInstance x, TechInstance y) => x.tech.tier.CompareTo(y.tech.tier)); activeResearch = queuedTech[0]; } } else { queuedTech.Clear(); } Trigger(-1914338957, queuedTech); CheckBuyResearch(); CheckResearchBuildings(null); if (activeResearch != null) { if (activeResearch.tech.costsByResearchTypeID.Count > 1) { if (!MinionResume.AnyMinionHasPerk(Db.Get().SkillPerks.AllowAdvancedResearch.Id)) { notifier.Remove(NoResearcherRole); notifier.Add(NoResearcherRole, string.Empty); } } else { notifier.Remove(NoResearcherRole); } if (activeResearch.tech.costsByResearchTypeID.Count > 2) { if (!MinionResume.AnyMinionHasPerk(Db.Get().SkillPerks.AllowInterstellarResearch.Id)) { notifier.Remove(NoResearcherRole); notifier.Add(NoResearcherRole, string.Empty); } } else { notifier.Remove(NoResearcherRole); } } else { notifier.Remove(NoResearcherRole); } }
// Use this for initialization private void Awake() { m_DictActivity = new Dictionary <Layer, List <Activity> >(); m_DictActivity[Layer.Game] = new List <Activity>(); m_DictActivity[Layer.System] = new List <Activity>(); m_WaitNextFrame = new WaitForEndOfFrame(); m_QueueProcess = new Queue <LoadAssetProcess>(); m_Notifier = new Notifier(this); m_Notifier.Add(NotificationType.EnqueueAProcess, OnEnqueueAProcessHandler); m_Notifier.Add(NotificationType.AddActivity, OnAddActivityHandler); m_Notifier.Add(NotificationType.RemoveActivity, OnRemoveActivityHandler); }
public void Start() { this.property = new BaseProperty(this); Notifier notifier = Notifier.GetInstance(); notifier.Add(this, this.property); }
protected override void OnStartWork(Worker worker) { base.OnStartWork(worker); notification = new Notification(MISC.NOTIFICATIONS.GENESHUFFLER.NAME, NotificationType.Good, HashedString.Invalid, (List<Notification> notificationList, object data) => MISC.NOTIFICATIONS.GENESHUFFLER.TOOLTIP + notificationList.ReduceMessages(false), null, false, 0f, null, null, null); notifier.Add(notification, string.Empty); DeSelectBuilding(); }
public Case(Notifier <T> notifier, string operation, T _targetValue, string subProp = null, bool wildcard = false) { bitOperator = BitOperator.AND; this.operation = operation; //targetIsFunction = Reflect.isFunction(_targetValue); //if (targetIsFunction) _targetFunction = _targetValue; //else this._targetValue = _targetValue; this._targetValue = _targetValue; this.notifier = notifier; this.subProp = subProp; if (operation == Operation.EQUAL) { if (wildcard) { getValue = wildcardEqualTo; } else { getValue = equalTo; } } else if (operation == Operation.NOT_EQUAL) { getValue = notEqualTo; } else if (operation == Operation.LESS_THAN_OR_EQUAL) { getValue = lessThanOrEqualTo; } else if (operation == Operation.LESS_THAN) { getValue = lessThan; } else if (operation == Operation.GREATER_THAN_OR_EQUAL) { getValue = greaterThanOrEqualTo; } else if (operation == Operation.GREATER_THAN) { getValue = greaterThan; } //super(); notifier.Add((value) => { //Console.WriteLine("value = " + value); check(); }); check(); /* * notifier.add(() -> { * check(); * }, 1000); * check(); */ }
private void RefreshNotifications() { foreach (var notification in notifications.ToList()) { Notifier notifier = notification.Notifier; notification.Clear(); notifier.Add(notification); } }
//var timer:Timer; public Condition(Action activeCallback, Action inactiveCallback) { onActive = new SignalA(active, true); onInactive = new SignalA(active, false); active.Add((value) => { if (value) { onActive.Dispatch(); } else { onInactive.Dispatch(); } }); onActive.Add(activeCallback); onInactive.Add(inactiveCallback); }
void Start() { this.property = new BaseProperty(this); this.stateMachine = new FiniteStateMachine <ARCoreBehaviour>(this); this.stateMachine.Add("detect", new ARCoreDetectState()); this.stateMachine.Add("tracking", new ARCoreTrackingState()); this.stateMachine.Stop(); Notifier notifier = Notifier.GetInstance(); notifier.Add(this, this.property); return; }
// Use this for initialization void Start() { this.property = new BaseProperty(this); this.stateMachine = new FiniteStateMachine <CanvasBehaviour>(this); this.stateMachine.Add("show", new CanvasShowState()); this.stateMachine.Add("hide", new CanvasHideState()); this.stateMachine.Change("show"); this.stateMachine.Play(); Notifier notifier = Notifier.GetInstance(); notifier.Add(this, this.property); return; }
public static void ExecuteNotification(GameObject obj) { Notification result = new Notification("Pipe Overpressure", NotificationType.BadMinor, HashedString.Invalid, null, null, true, 0f, null, null, obj.transform, true); Notifier notifier = Game.Instance.FindOrAdd <Notifier>(); if (lastNotification != null) { notifier.Remove(lastNotification); lastNotification = null; } notifier.Add(result); lastNotification = result; }
private void OnNightTime(object data) { dailyReports.Add(todaysReport); int day = todaysReport.day; Notification notification = new Notification(string.Format(UI.ENDOFDAYREPORT.NOTIFICATION_TITLE, day), NotificationType.Good, HashedString.Invalid, (List <Notification> n, object d) => string.Format(UI.ENDOFDAYREPORT.NOTIFICATION_TOOLTIP, day), null, true, 0f, delegate { ManagementMenu.Instance.OpenReports(day); }, null, null); if ((UnityEngine.Object)notifier == (UnityEngine.Object)null) { Debug.LogError("Cant notify, null notifier"); } else { notifier.Add(notification, string.Empty); } todaysReport = new DailyReport(this); todaysReport.day = GameUtil.GetCurrentCycle() + 1; }
// Use this for initialization void Start() { this.enableTouch = false; this.property = new BaseProperty(this); this.stateMachine = new FiniteStateMachine <IconBehaviour>(this); this.stateMachine.Add("show", new IconShowState()); this.stateMachine.Add("hide", new IconHideState()); this.stateMachine.Add("beat", new IconBeatState()); this.stateMachine.Add("jump", new IconJumpState()); this.stateMachine.Stop(); this.vortexVfx = GameObject.Find("VortexVfx"); this.hitVfx = GameObject.Find("HitVfx"); this.vortexVfx.SetActive(false); this.hitVfx.SetActive(false); this.transform.position = Vector3.zero; this.StartCoroutine("OnLoad"); Notifier notifier = Notifier.GetInstance(); notifier.Add(this, this.property); return; }
private void PlaceDiggables() { if (waitForFetchesBeforeDigging && fetchList != null && !hasLadderNearby) { OnDiggableReachabilityChanged(null); } else { bool digs_complete = true; if (!solidPartitionerEntry.IsValid()) { Extents validPlacementExtents = building.GetValidPlacementExtents(); solidPartitionerEntry = GameScenePartitioner.Instance.Add("Constructable.OnFetchListComplete", base.gameObject, validPlacementExtents, GameScenePartitioner.Instance.solidChangedLayer, OnSolidChangedOrDigDestroyed); digPartitionerEntry = GameScenePartitioner.Instance.Add("Constructable.OnFetchListComplete", base.gameObject, validPlacementExtents, GameScenePartitioner.Instance.digDestroyedLayer, OnSolidChangedOrDigDestroyed); } if (!IsReplacementTile) { building.RunOnArea(delegate(int offset_cell) { PrioritySetting masterPriority = GetComponent <Prioritizable>().GetMasterPriority(); if (Diggable.IsDiggable(offset_cell)) { digs_complete = false; Diggable diggable = Diggable.GetDiggable(offset_cell); if ((UnityEngine.Object)diggable == (UnityEngine.Object)null) { diggable = GameUtil.KInstantiate(Assets.GetPrefab(new Tag("DigPlacer")), Grid.SceneLayer.Move, null, 0).GetComponent <Diggable>(); diggable.gameObject.SetActive(true); diggable.transform.SetPosition(Grid.CellToPosCBC(offset_cell, Grid.SceneLayer.Move)); diggable.Subscribe(-1432940121, OnDiggableReachabilityChanged); Grid.Objects[offset_cell, 7] = diggable.gameObject; } else { diggable.Unsubscribe(-1432940121, OnDiggableReachabilityChanged); diggable.Subscribe(-1432940121, OnDiggableReachabilityChanged); } diggable.choreTypeIdHash = Db.Get().ChoreTypes.BuildDig.IdHash; diggable.GetComponent <Prioritizable>().SetMasterPriority(masterPriority); RenderUtil.EnableRenderer(diggable.transform, false); SaveLoadRoot component = diggable.GetComponent <SaveLoadRoot>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { UnityEngine.Object.Destroy(component); } } }); OnDiggableReachabilityChanged(null); } bool flag = building.Def.IsValidBuildLocation(base.gameObject, base.transform.GetPosition(), building.Orientation); if (flag) { notifier.Remove(invalidLocation); } else { notifier.Add(invalidLocation, string.Empty); } GetComponent <KSelectable>().ToggleStatusItem(Db.Get().BuildingStatusItems.InvalidBuildingLocation, !flag, this); bool flag2 = digs_complete && flag && fetchList == null; if (flag2 && buildChore == null) { buildChore = new WorkChore <Constructable>(Db.Get().ChoreTypes.Build, this, null, true, UpdateBuildState, UpdateBuildState, UpdateBuildState, true, null, false, true, null, true, true, true, PriorityScreen.PriorityClass.basic, 5, false, true); UpdateBuildState(buildChore); } else if (!flag2 && buildChore != null) { buildChore.Cancel("Need to dig"); buildChore = null; } } }
public static bool Prefix(ElectricalUtilityNetwork __instance, float dt, float watts_used, List <WireUtilityNetworkLink>[] bridgeGroups, ref float ___timeOverloaded, ref GameObject ___targetOverloadedWire, ref Notification ___overloadedNotification, ref float ___timeOverloadNotificationDisplayed, List <Wire>[] ___wireGroups) { Log.Spam($"UpdateOverloadTime: {___wireGroups.Length}, {bridgeGroups.Length}"); bool wattage_rating_exceeded = false; List <Wire> overloaded_wires = null; List <WireUtilityNetworkLink> overloaded_bridges = null; for (int rating_idx = 0; rating_idx < ___wireGroups.Length; rating_idx++) { List <Wire> wires = ___wireGroups[rating_idx]; List <WireUtilityNetworkLink> bridges = bridgeGroups[rating_idx]; Wire.WattageRating rating = (Wire.WattageRating)rating_idx; float max_wattage = Wire.GetMaxWattageAsFloat(rating); if (watts_used > max_wattage && ((bridges != null && bridges.Count > 0) || (wires != null && wires.Count > 0))) { wattage_rating_exceeded = true; overloaded_wires = wires; overloaded_bridges = bridges; break; } } overloaded_wires?.RemoveAll((Wire x) => x == null); overloaded_bridges?.RemoveAll((WireUtilityNetworkLink x) => x == null); if (wattage_rating_exceeded) { ___timeOverloaded += dt; if (!(___timeOverloaded > 6f)) { return(false); } ___timeOverloaded = 0f; if (___targetOverloadedWire == null) { if (overloaded_bridges != null && overloaded_bridges.Count > 0) { int random_bridge_idx = Random.Range(0, overloaded_bridges.Count); ___targetOverloadedWire = overloaded_bridges[random_bridge_idx].gameObject; } else if (overloaded_wires != null && overloaded_wires.Count > 0) { int random_wire_idx = Random.Range(0, overloaded_wires.Count); ___targetOverloadedWire = overloaded_wires[random_wire_idx].gameObject; } } if (___targetOverloadedWire != null) { ___targetOverloadedWire.Trigger(-794517298, new BuildingHP.DamageSourceInfo { damage = 1, source = STRINGS.BUILDINGS.DAMAGESOURCES.CIRCUIT_OVERLOADED, popString = STRINGS.UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.CIRCUIT_OVERLOADED, takeDamageEffect = SpawnFXHashes.BuildingSpark, fullDamageEffectName = "spark_damage_kanim", statusItemID = Db.Get().BuildingStatusItems.Overloaded.Id }); } if (___overloadedNotification == null) { ___timeOverloadNotificationDisplayed = 0f; ___overloadedNotification = new Notification(STRINGS.MISC.NOTIFICATIONS.CIRCUIT_OVERLOADED.NAME, NotificationType.BadMinor, HashedString.Invalid, null, null, true, 0f, null, null, ___targetOverloadedWire.transform); GameScheduler.Instance.Schedule("Power Tutorial", 2f, delegate { Tutorial.Instance.TutorialMessage(Tutorial.TutorialMessages.TM_Power); }); Notifier notifier = Game.Instance.FindOrAdd <Notifier>(); notifier.Add(___overloadedNotification); } } else { ___timeOverloaded = Mathf.Max(0f, ___timeOverloaded - dt * 0.95f); ___timeOverloadNotificationDisplayed += dt; if (___timeOverloadNotificationDisplayed > 5f) { Traverse.Create(__instance).Method("RemoveOverloadedNotification").GetValue(); } } return(false); }
public static void registerNotification(Enum type, Action <Notification> receiver) { notifier.Add(type, receiver); }
public BaseTick(Action callback) { this.callback = callback; running.Add(onRunningChange); }
private void StartAttack() { timeKeeper.Resume("hit"); timeKeeper.Resume("game"); notifier.Add(0, "We are under attack!!"); }
public void AddNotifier(INotifier win) { Notifier.Add(win); }
private void OnNewMessage(object data) { Message m = (Message)data; notifier.Add(new MessageNotification(m), string.Empty); }
public void UpdateOverloadTime(float dt, float watts_used, List <WireUtilityNetworkLink>[] bridgeGroups) { bool flag = false; List <Wire> list = null; List <WireUtilityNetworkLink> list2 = null; for (int i = 0; i < 5; i++) { List <Wire> list3 = wireGroups[i]; List <WireUtilityNetworkLink> list4 = bridgeGroups[i]; Wire.WattageRating rating = (Wire.WattageRating)i; float maxWattageAsFloat = Wire.GetMaxWattageAsFloat(rating); if (watts_used > maxWattageAsFloat && ((list4 != null && list4.Count > 0) || (list3 != null && list3.Count > 0))) { flag = true; list = list3; list2 = list4; break; } } list?.RemoveAll((Wire x) => (Object)x == (Object)null); list2?.RemoveAll((WireUtilityNetworkLink x) => (Object)x == (Object)null); if (flag) { timeOverloaded += dt; if (timeOverloaded > 6f) { timeOverloaded = 0f; if ((Object)targetOverloadedWire == (Object)null) { if (list2 != null && list2.Count > 0) { int index = Random.Range(0, list2.Count); targetOverloadedWire = list2[index].gameObject; } else if (list != null && list.Count > 0) { int index2 = Random.Range(0, list.Count); targetOverloadedWire = list[index2].gameObject; } } if ((Object)targetOverloadedWire != (Object)null) { targetOverloadedWire.Trigger(-794517298, new BuildingHP.DamageSourceInfo { damage = 1, source = (string)BUILDINGS.DAMAGESOURCES.CIRCUIT_OVERLOADED, popString = (string)UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.CIRCUIT_OVERLOADED, takeDamageEffect = SpawnFXHashes.BuildingSpark, fullDamageEffectName = "spark_damage_kanim", statusItemID = Db.Get().BuildingStatusItems.Overloaded.Id }); } if (overloadedNotification == null) { timeOverloadNotificationDisplayed = 0f; string title = MISC.NOTIFICATIONS.CIRCUIT_OVERLOADED.NAME; NotificationType type = NotificationType.BadMinor; HashedString invalid = HashedString.Invalid; Transform transform = targetOverloadedWire.transform; overloadedNotification = new Notification(title, type, invalid, null, null, true, 0f, null, null, transform); Notifier notifier = Game.Instance.FindOrAdd <Notifier>(); notifier.Add(overloadedNotification, string.Empty); } } } else { timeOverloaded = Mathf.Max(0f, timeOverloaded - dt * 0.95f); timeOverloadNotificationDisplayed += dt; if (timeOverloadNotificationDisplayed > 5f) { RemoveOverloadedNotification(); } } }