/// <summary> /// Applied after Render1000ms runs. /// </summary> internal static void Postfix(SingleEntityReceptacle __instance, float dt) { if (__instance is ArtifactModule am) // and is thus not null too! { ArtifactModuleRenderer.RenderEveryTick(am, dt); } }
public override void SetTarget(GameObject target) { SingleEntityReceptacle component = target.GetComponent <SingleEntityReceptacle>(); if ((Object)component == (Object)null) { Debug.LogError("The object selected doesn't have a SingleObjectReceptacle!"); } else { Initialize(component); UpdateState(null); } }
public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag) { go.AddOrGet <Storage>().SetDefaultStoredItemModifiers(new List <Storage.StoredItemModifier>(new Storage.StoredItemModifier[] { Storage.StoredItemModifier.Seal, Storage.StoredItemModifier.Preserve })); Prioritizable.AddRef(go); SingleEntityReceptacle singleEntityReceptacle = go.AddOrGet <SingleEntityReceptacle>(); singleEntityReceptacle.AddDepositTag(GameTags.Artifact); singleEntityReceptacle.occupyingObjectRelativePosition = new Vector3(0f, 1.2f, -1f); go.AddOrGet <DecorProvider>(); go.AddOrGet <ItemPedestal>(); go.GetComponent <KPrefabID>().AddTag(GameTags.Decoration, false); }
public override void ClearTarget() { if ((Object)targetReceptacle != (Object)null) { if (CheckReceptacleOccupied()) { targetReceptacle.Occupant.gameObject.Unsubscribe(onObjectDestroyedHandle); onObjectDestroyedHandle = -1; } targetReceptacle.Unsubscribe(onStorageChangedHandle); onStorageChangedHandle = -1; targetReceptacle.Unsubscribe(onOccupantValidChangedHandle); onOccupantValidChangedHandle = -1; if (targetReceptacle.GetActiveRequest == null) { targetReceptacle.SetPreview(Tag.Invalid, false); } SimAndRenderScheduler.instance.Remove(this); targetReceptacle = null; } }
public void Initialize(SingleEntityReceptacle target) { if ((Object)target == (Object)null) { Debug.LogError("SingleObjectReceptacle provided was null."); } else { targetReceptacle = target; base.gameObject.SetActive(true); depositObjectMap = new Dictionary <ReceptacleToggle, SelectableEntity>(); entityToggles.ForEach(delegate(ReceptacleToggle rbi) { Object.Destroy(rbi.gameObject); }); entityToggles.Clear(); Tag[] possibleDepositObjectTags = target.possibleDepositObjectTags; ReceptacleToggle newToggle; foreach (Tag tag in possibleDepositObjectTags) { List <GameObject> prefabsWithTag = Assets.GetPrefabsWithTag(tag); if ((Object)targetReceptacle.rotatable == (Object)null) { prefabsWithTag.RemoveAll(delegate(GameObject go) { IReceptacleDirection component3 = go.GetComponent <IReceptacleDirection>(); return(component3 != null && component3.Direction != targetReceptacle.Direction); }); } List <IHasSortOrder> list = new List <IHasSortOrder>(); foreach (GameObject item in prefabsWithTag) { IHasSortOrder component = item.GetComponent <IHasSortOrder>(); if (component != null) { list.Add(component); } } Debug.Assert(list.Count == prefabsWithTag.Count, "Not all entities in this receptacle implement IHasSortOrder!"); list.Sort((IHasSortOrder a, IHasSortOrder b) => a.sortOrder - b.sortOrder); foreach (IHasSortOrder item2 in list) { GameObject gameObject = (item2 as MonoBehaviour).gameObject; GameObject gameObject2 = Util.KInstantiateUI(entityToggle, requestObjectList, false); gameObject2.SetActive(true); newToggle = gameObject2.GetComponent <ReceptacleToggle>(); IReceptacleDirection component2 = gameObject.GetComponent <IReceptacleDirection>(); string properName = gameObject.GetProperName(); newToggle.title.text = properName; Sprite entityIcon = GetEntityIcon(gameObject.PrefabID()); if ((Object)entityIcon == (Object)null) { entityIcon = elementPlaceholderSpr; } newToggle.image.sprite = entityIcon; newToggle.toggle.onClick += delegate { ToggleClicked(newToggle); }; newToggle.toggle.onPointerEnter += delegate { CheckAmountsAndUpdate(null); }; depositObjectMap.Add(newToggle, new SelectableEntity { tag = gameObject.PrefabID(), direction = (component2?.Direction ?? SingleEntityReceptacle.ReceptacleDirection.Top), asset = gameObject }); entityToggles.Add(newToggle); } } selectedEntityToggle = null; if (entityToggles.Count > 0) { if (entityPreviousSelectionMap.ContainsKey(targetReceptacle)) { int index = entityPreviousSelectionMap[targetReceptacle]; ToggleClicked(entityToggles[index]); } else { subtitleLabel.SetText(Strings.Get(subtitleStringSelect).ToString()); requestSelectedEntityBtn.isInteractable = false; descriptionLabel.SetText(Strings.Get(subtitleStringSelectDescription).ToString()); HideAllDescriptorPanels(); } } onStorageChangedHandle = targetReceptacle.gameObject.Subscribe(-1697596308, CheckAmountsAndUpdate); onOccupantValidChangedHandle = targetReceptacle.gameObject.Subscribe(-1820564715, OnOccupantValidChanged); UpdateState(null); SimAndRenderScheduler.instance.Add(this, false); } }