protected override void OnSpawn() { base.OnSpawn(); conditionManager = FindLaunchConditionManager(); Spacecraft spacecraftFromLaunchConditionManager = SpacecraftManager.instance.GetSpacecraftFromLaunchConditionManager(conditionManager); if (spacecraftFromLaunchConditionManager != null) { SetParentRocketName(spacecraftFromLaunchConditionManager.GetRocketName()); } RegisterWithConditionManager(); KSelectable component = GetComponent <KSelectable>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { component.AddStatusItem(Db.Get().BuildingStatusItems.RocketName, this); } if ((UnityEngine.Object)conditionManager != (UnityEngine.Object)null && conditionManager.GetComponent <KPrefabID>().HasTag(GameTags.RocketNotOnGround)) { OnLaunch(null); } Subscribe(-1056989049, OnLaunchDelegate); Subscribe(238242047, OnLandDelegate); Subscribe(1502190696, DEBUG_OnDestroyDelegate); FixSorting(); AttachableBuilding component2 = GetComponent <AttachableBuilding>(); component2.onAttachmentNetworkChanged = (Action <AttachableBuilding>)Delegate.Combine(component2.onAttachmentNetworkChanged, new Action <AttachableBuilding>(OnAttachmentNetworkChanged)); if ((UnityEngine.Object)bgAnimFile != (UnityEngine.Object)null) { AddBGGantry(); } }
void GetRocketComponents() { List <GameObject> attachedNetwork = AttachableBuilding.GetAttachedNetwork(this.GetComponent <AttachableBuilding>()); foreach (GameObject gameObject in attachedNetwork) { CommandModule component = gameObject.GetComponent <CommandModule>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { relatedCM = component; } } if (relatedCM == null) { return; } LaunchConditionManager conditionManager = relatedCM.gameObject.GetComponent <LaunchConditionManager>(); if (conditionManager == null) { return; } relatedSpacecraft = SpacecraftManager.instance.GetSpacecraftFromLaunchConditionManager(conditionManager); }
public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag) { BuildingConfigManager.Instance.IgnoreDefaultKComponent(typeof(RequiresFoundation), prefab_tag); go.AddOrGet <LoopingSounds>(); go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery, false); RocketModule rocketModule = go.AddOrGet <RocketModule>(); rocketModule.SetBGKAnim(Assets.GetAnim("rocket_command_module_bg_kanim")); LaunchConditionManager launchConditionManager = go.AddOrGet <LaunchConditionManager>(); launchConditionManager.triggerPort = "TriggerLaunch"; launchConditionManager.statusPort = "LaunchReady"; Storage storage = go.AddOrGet <Storage>(); storage.SetDefaultStoredItemModifiers(new List <Storage.StoredItemModifier> { Storage.StoredItemModifier.Hide, Storage.StoredItemModifier.Seal, Storage.StoredItemModifier.Insulate }); go.AddOrGet <CommandModule>(); go.AddOrGet <CommandModuleWorkable>(); go.AddOrGet <MinionStorage>(); go.AddOrGet <ArtifactFinder>(); go.AddOrGet <LaunchableRocket>(); }
public override void Update(float dt) { foreach (Entry entry in entries) { Entry current = entry; if (!((Object)current.rocketModule == (Object)null)) { LaunchConditionManager conditionManager = current.rocketModule.conditionManager; if (!((Object)conditionManager == (Object)null)) { LaunchableRocket component = conditionManager.GetComponent <LaunchableRocket>(); if (!((Object)component == (Object)null)) { if (component.isLanding) { current.ev.setParameterValueByIndex(current.parameterIdx, 1f); } else { current.ev.setParameterValueByIndex(current.parameterIdx, 0f); } } } } } }
public LaunchConditionManager FindLaunchConditionManager() { List <GameObject> attachedNetwork = AttachableBuilding.GetAttachedNetwork(GetComponent <AttachableBuilding>()); foreach (GameObject item in attachedNetwork) { LaunchConditionManager component = item.GetComponent <LaunchConditionManager>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { return(component); } } return(null); }
private void SetRow(int idx, string name, Sprite icon, LaunchConditionManager target) { GameObject gameObject = (idx >= rowContainer.childCount) ? Util.KInstantiateUI(rowPrefab, rowContainer.gameObject, true) : rowContainer.GetChild(idx).gameObject; HierarchyReferences component = gameObject.GetComponent <HierarchyReferences>(); component.GetReference <LocText>("label").text = name; component.GetReference <Image>("icon").sprite = icon; MultiToggle component2 = gameObject.GetComponent <MultiToggle>(); component2.ChangeState(((Object)detector.GetTargetCraft() == (Object)target) ? 1 : 0); component2.onClick = delegate { detector.SetTargetCraft(target); RefreshOptions(); }; }
private void SetRow(int idx, string name, Sprite icon, LaunchConditionManager target) { GameObject gameObject = idx >= this.rowContainer.childCount ? Util.KInstantiateUI(this.rowPrefab, this.rowContainer.gameObject, true) : this.rowContainer.GetChild(idx).gameObject; HierarchyReferences component1 = gameObject.GetComponent <HierarchyReferences>(); component1.GetReference <LocText>("label").text = name; component1.GetReference <Image>(nameof(icon)).sprite = icon; MultiToggle component2 = gameObject.GetComponent <MultiToggle>(); component2.ChangeState((UnityEngine.Object) this.detector.GetTargetCraft() == (UnityEngine.Object)target ? 1 : 0); LaunchConditionManager _target = target; component2.onClick = (System.Action)(() => { this.detector.SetTargetCraft(_target); this.RefreshOptions(); }); }
public override void SetTarget(GameObject new_target) { if ((UnityEngine.Object)new_target == (UnityEngine.Object)null) { Debug.LogError("Invalid gameObject received"); } else { target = new_target.GetComponent <LaunchConditionManager>(); if ((UnityEngine.Object)target == (UnityEngine.Object)null) { Debug.LogError("The gameObject received does not contain a LaunchConditionManager component"); } else { ClearConditions(); ConfigureConditions(); debugVictoryButton.gameObject.SetActive(DebugHandler.InstantBuildMode && CheckHydrogenRocket()); } } }
public void SetTargetCraft(LaunchConditionManager target) => this.targetCraft.Set(target);