// Load seamoth doll state public void OnProtoDeserialize(ProtobufSerializer serializer) { PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { return; } } string filePath = Path.Combine(FilesHelper.GetSaveFolderPath(), "seamothdoll_" + id.Id + ".txt"); if (File.Exists(filePath)) { string state = File.ReadAllText(filePath).Trim(); GameObject extras = this.gameObject.FindChild("Model").FindChild("Submersible_SeaMoth_extras"); Renderer[] renderers = extras.GetAllComponentsInChildren <Renderer>(); foreach (Renderer renderer in renderers) { renderer.enabled = (string.Compare(state, "1", false, CultureInfo.InvariantCulture) == 0); } } }
private bool ValidateCollider(Collider other) { if (Grabber.FocusedItem != other) { PrefabIdentifier componentInParent = other.GetComponentInParent <PrefabIdentifier>(); if (componentInParent) { BuildingHealth component = componentInParent.GetComponent <BuildingHealth>(); if (component && component.CanBeRepaired && (component.CalcMissingRepairMaterial() > 0 || component.CalcMissingRepairLogs() > 0) && LocalPlayer.Inventory.Logs.HasLogs == component.CalcMissingRepairLogs() > 0) { return(!other.isTrigger); } FoundationHealth component2 = componentInParent.GetComponent <FoundationHealth>(); if (component2 && component2.CanBeRepaired) { bool flag = component2.CalcMissingRepairMaterial() > 0; bool flag2 = component2.CalcMissingRepairLogs() > 0; if (!LocalPlayer.Inventory.Logs.HasLogs == flag || (LocalPlayer.Inventory.Logs.HasLogs && flag2)) { return(!other.isTrigger); } } } } return(LocalPlayer.Grabber.IsValid(other)); }
public override GameObject GetGameObject() { try { if (_prefab == null) { QuickLogger.Error("Bottle Prefab is null", true); return(null); } var prefab = GameObject.Instantiate(_prefab); prefab.name = this.PrefabFileName; PrefabIdentifier prefabID = prefab.EnsureComponent <PrefabIdentifier>(); prefabID.ClassId = this.ClassID; var techTag = prefab.EnsureComponent <TechTag>(); techTag.type = TechType; //Add the FCSTechFabricatorTag component prefab.AddComponent <FCSTechFabricatorTag>(); return(prefab); } catch (Exception e) { QuickLogger.Error(e.Message); return(null); } }
private void Update() { if (this._raft.MultiPointsPositions.Count == 0) { RaycastHit raycastHit; if (Physics.SphereCast(((this._origin != RaftOarSwap.RayCastOrigins.Player) ? LocalPlayer.Create.BuildingPlacer.transform.position : LocalPlayer.MainCamTr.position) + Vector3.up * 3f, 2f, Vector3.down, out raycastHit, this._raycastDistance, this._layers.value)) { PrefabIdentifier componentInParent = raycastHit.collider.GetComponentInParent <PrefabIdentifier>(); RaftArchitect raftArchitect = (!componentInParent) ? null : componentInParent.GetComponent <RaftArchitect>(); bool flag = raftArchitect && raftArchitect._wasBuilt; if (flag) { this._oarGo.SetActive(true); this._raftGo.SetActive(false); LocalPlayer.Create.Grabber.ShowPlace(); LocalPlayer.Create.BuildingPlacer.SetClear(); LocalPlayer.Create.BuildingPlacer.SetRenderer(this._oarRenderer); } else if (this._oarGo.activeSelf) { this._oarGo.SetActive(false); this._raftGo.SetActive(true); LocalPlayer.Create.Grabber.ClosePlace(); LocalPlayer.Create.BuildingPlacer.SetRenderer(this._raftRenderer); } } else if (!this._raftGo.activeSelf) { this._oarGo.SetActive(false); this._raftGo.SetActive(true); LocalPlayer.Create.Grabber.ClosePlace(); LocalPlayer.Create.BuildingPlacer.SetRenderer(this._raftRenderer); } } }
public void OnProtoDeserialize(ProtobufSerializer serializer) { PrefabIdentifier prefabIdentifier = GetComponent <PrefabIdentifier>(); Debug.Log($"Deserializing {prefabIdentifier.Id}"); string oldDataPath = QPatch.GetOldSaveDirectory(); oldDataPath = string.Concat(oldDataPath, prefabIdentifier.Id, ".json"); //Port old data if (File.Exists(oldDataPath)) { Debug.Log($"Loading {prefabIdentifier.Id} from old data"); BaseClockSaveData saveData = JsonConvert.DeserializeObject <BaseClockSaveData>(File.ReadAllText(oldDataPath)); m_UseSystemTime = saveData.usesSystemTime; UseSystemTimeSet(m_UseSystemTime); File.Delete(oldDataPath); Debug.Log($"Ported {prefabIdentifier.Id}"); } else { string containerPath = Path.Combine("BaseClocks", $"{prefabIdentifier.Id}.json"); BaseClocksCoroutineRunner.Instance.StartCoroutine(DeserializeCoroutine(containerPath)); } }
public override GameObject GetGameObject() { try { var prefab = GameObject.Instantiate(_gameObjectKit); if (SetKitLabel(prefab)) { prefab.name = this.PrefabFileName; PrefabIdentifier prefabID = prefab.EnsureComponent <PrefabIdentifier>(); prefabID.ClassId = this.ClassID; var techTag = prefab.EnsureComponent <TechTag>(); techTag.type = TechType; var center = new Vector3(0f, 0.2518765f, 0f); var size = new Vector3(0.5021304f, 0.5062426f, 0.5044461f); GameObjectHelpers.AddConstructableBounds(prefab, size, center); //Add the FCSTechFabricatorTag component prefab.AddComponent <FCSTechFabricatorTag>(); return(prefab); } } catch (Exception e) { QuickLogger.Error(e.Message); } return(null); }
private void Awake() { foreach (BuildingBlueprint buildingBlueprint in this._blueprints) { if (buildingBlueprint._ghostPrefab) { PrefabIdentifier component = buildingBlueprint._ghostPrefab.GetComponent <PrefabIdentifier>(); if (component && !this._blueprintsByGuid.ContainsKey(component.ClassId)) { this._blueprintsByGuid.Add(component.ClassId, buildingBlueprint); } } if (buildingBlueprint._ghostPrefabMP) { PrefabIdentifier component2 = buildingBlueprint._ghostPrefabMP.GetComponent <PrefabIdentifier>(); if (component2 && !this._blueprintsByGuid.ContainsKey(component2.ClassId)) { this._blueprintsByGuid.Add(component2.ClassId, buildingBlueprint); } } if (buildingBlueprint._builtPrefab) { PrefabIdentifier component3 = buildingBlueprint._builtPrefab.GetComponent <PrefabIdentifier>(); if (component3 && !this._blueprintsByGuid.ContainsKey(component3.ClassId)) { this._blueprintsByGuid.Add(component3.ClassId, buildingBlueprint); } } if (buildingBlueprint._exclusionGroup != ExclusionGroups.None) { this._exclusionGroupByTypes.Add(buildingBlueprint._type, buildingBlueprint._exclusionGroup); } } }
// Token: 0x0600000D RID: 13 RVA: 0x00002290 File Offset: 0x00000490 public GameObject GetHullPlate() { bool flag = this.Texture == null; GameObject result; if (flag) { result = null; } else { GameObject gameObject = Resources.Load <GameObject>("Submarine/Build/DioramaHullPlate"); GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(gameObject); MeshRenderer component = Radical.FindChild(gameObject2, "Icon").GetComponent <MeshRenderer>(); component.material.mainTexture = this.Texture; PrefabIdentifier component2 = gameObject2.GetComponent <PrefabIdentifier>(); component2.ClassId = this.Info.InternalName; TechTag component3 = gameObject2.GetComponent <TechTag>(); component3.type = this.TechType; Constructable component4 = gameObject2.GetComponent <Constructable>(); component4.techType = this.TechType; result = gameObject2; } return(result); }
public void OnProtoDeserialize(ProtobufSerializer serializer) { PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { return; } } string filePath = Path.Combine(FilesHelper.GetSaveFolderPath(), "forklift_" + id.Id + ".txt"); if (File.Exists(filePath)) { string tmpSize = File.ReadAllText(filePath).Replace(',', '.'); // Replace , with . for backward compatibility. string[] sizes = tmpSize.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (sizes.Length == 2) { GameObject model = this.gameObject.FindChild("forklift"); if (model != null) { float size = float.Parse(sizes[0], CultureInfo.InvariantCulture); model.transform.localScale = new Vector3(size, size, size); } BoxCollider collider = this.gameObject.GetComponent <BoxCollider>(); if (collider != null) { float colliderSize = float.Parse(sizes[1], CultureInfo.InvariantCulture); collider.size = new Vector3(colliderSize, colliderSize, colliderSize); } } } }
public static void Construct_Postfix(Constructable __instance) { if (__instance.techType == CrafterLogicFixer.OutdoorLadder) { GameObject ladder = __instance.gameObject; if (ladder != null) { PrefabIdentifier pid = ladder.GetComponent <PrefabIdentifier>(); if (pid != null) { Transform modelTr = ladder.FindChild("OutdoorLadderModel")?.transform; if (modelTr != null) { Vector3 modelPos = modelTr.position; if (BuilderFixer.TempLadderDirections.ContainsKey(modelPos)) { int direction = BuilderFixer.TempLadderDirections[modelPos].Key; bool inverted = BuilderFixer.TempLadderDirections[modelPos].Value; LadderDirections[pid.Id] = new KeyValuePair <int, bool>(direction, inverted); } } } } BuilderFixer.TempLadderDirections.Clear(); } }
public void OnProtoSerialize(ProtobufSerializer serializer) { PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null) { if ((id = GetComponent <PrefabIdentifier>()) == null) { return; } } string saveFolder = FilesHelper.GetSaveFolderPath(); if (!Directory.Exists(saveFolder)) { Directory.CreateDirectory(saveFolder); } GameObject model = this.gameObject.FindChild("forklift"); string size = Convert.ToString(model.transform.localScale.y, CultureInfo.InvariantCulture); BoxCollider collider = this.gameObject.GetComponent <BoxCollider>(); size += Environment.NewLine + Convert.ToString(collider.size.y, CultureInfo.InvariantCulture); File.WriteAllText(Path.Combine(saveFolder, "forklift_" + id.Id + ".txt"), size); }
public void Start() { PrefabIdentifier prefabIdentifier = GetComponentInParent <PrefabIdentifier>(); if ((prefabIdentifier ??= GetComponent <PrefabIdentifier>()) is null) { return; } ColorInfo colorInfo; string saveFolder = Main.GetSaveFolderPath(); string filePath = Main.Combine(saveFolder, prefabIdentifier.Id + ".json"); using (StreamReader reader = new StreamReader(filePath)) { var serializer = new JsonSerializer(); colorInfo = serializer.Deserialize(reader, typeof(ColorInfo)) as ColorInfo; } if (File.Exists(filePath)) { if (colorInfo != null) { savedColor = new Color(colorInfo.RedLevel, colorInfo.GreenLevel, colorInfo.BlueLevel); return; } Logger.Log(Logger.Level.Warn, "[Spotlight Colorizable] ColorInfo is null"); return; } Logger.Log(Logger.Level.Warn, "saved file doesn't exist"); }
public override GameObject GetGameObject() { try { var prefab = GameObject.Instantiate(_prefab); GameObjectHelpers.AddConstructableBounds(prefab, _bSize, _bCenter); var model = prefab.FindChild("model"); //========== Allows the building animation and material colors ==========// Shader shader = Shader.Find("MarmosetUBER"); Renderer[] renderers = prefab.GetComponentsInChildren <Renderer>(); SkyApplier skyApplier = prefab.EnsureComponent <SkyApplier>(); skyApplier.renderers = renderers; skyApplier.anchorSky = Skies.Auto; //========== Allows the building animation and material colors ==========// // Add large world entity ALLOWS YOU TO SAVE ON TERRAIN var lwe = prefab.AddComponent <LargeWorldEntity>(); lwe.cellLevel = LargeWorldEntity.CellLevel.Far; // Add constructible var constructable = prefab.AddComponent <Constructable>(); constructable.allowedOutside = true; constructable.allowedInBase = true; constructable.allowedOnGround = true; constructable.allowedOnWall = false; constructable.rotationEnabled = true; constructable.allowedOnCeiling = false; constructable.allowedInSub = true; constructable.allowedOnConstructables = false; constructable.model = model; constructable.techType = TechType; var light = prefab.GetComponentInChildren <Light>(); var lightR = prefab.AddComponent <RegistredLightSource>(); lightR.hostLight = light; PrefabIdentifier prefabID = prefab.AddComponent <PrefabIdentifier>(); prefabID.ClassId = ClassID; AddBubbles(prefab); AddVaporBlast(prefab); prefab.AddComponent <TechTag>().type = TechType; prefab.AddComponent <HydroHarvController>(); //Apply the glass shader here because of autosort lockers for some reason doesnt like it. MaterialHelpers.ApplyGlassShaderTemplate(prefab, "_glass", Mod.ModName); return(prefab); } catch (Exception e) { QuickLogger.Error(e.Message); return(null); } }
internal string GetPrefabId() { if (_prefabID == null) { _prefabID = GetComponent <PrefabIdentifier>() ?? GetComponentInParent <PrefabIdentifier>(); } return(_prefabID.Id); }
private void InitAnimation(GameObject go) { if (!Running) { #if DEBUG_FLORA PrefabIdentifier id = go.GetComponent <PrefabIdentifier>(); if (id != null) { Logger.Log("DEBUG: LandTree1Controller.Update(): gameObject name=[" + go.name + "] id=[" + id.Id + "] position x=[" + go.transform.localPosition.x + "] y=[" + go.transform.localPosition.y + "] z=[" + go.transform.localPosition.z + "] => Initializing"); } else { Logger.Log("DEBUG: LandTree1Controller.Update(): gameObject name=[" + go.name + "] position x=[" + go.transform.localPosition.x + "] y=[" + go.transform.localPosition.y + "] z=[" + go.transform.localPosition.z + "] => Initializing"); } #endif if (StaticPrefab != null) { // Configure static renderer StaticPrefab.transform.parent = go.transform; StaticPrefab.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f); StaticPrefab.transform.localScale = new Vector3(12f, 12f, 12f); StaticPrefab.transform.localEulerAngles = new Vector3(0.0f, 0.0f, 0.0f); // Update sky applier SkyApplier skyApplier = go.GetComponent <SkyApplier>(); skyApplier.renderers = go.GetComponentsInChildren <Renderer>(); skyApplier.anchorSky = Skies.Auto; StaticPrefab.SetActive(true); } // Hide seed model GameObject seed = _grownPlant.gameObject.FindChild("Generic_plant_seed"); if (seed != null) { seed.GetComponent <MeshRenderer>().enabled = false; } // Store init values _initTimeValue = DayNightCycle.main.timePassed; foreach (Transform tr in go.transform) { bool isStatic = tr.name.StartsWith("Land_tree_01_static", true, CultureInfo.InvariantCulture); if (_origScale == Vector3.zero && !isStatic) { _origScale = new Vector3(tr.localScale.x, tr.localScale.y, tr.localScale.z); } else if (_origStaticScale == Vector3.zero && isStatic) { _origStaticScale = new Vector3(tr.localScale.x, tr.localScale.y, tr.localScale.z); } } // Init trees sizes foreach (Transform tr in go.transform) { tr.localScale = new Vector3(0.0001f, 0.0001f, 0.0001f); } Running = true; } }
private void Initialize() { ToggleHash = Animator.StringToHash("ToggleState"); StateHash = Animator.StringToHash("state"); AutoActiveHash = Animator.StringToHash("AutoActivateState"); BaseDrainHash = Animator.StringToHash("BaseDrain"); SetCurrentBodyColor(new Color(0.99609375f, 0.99609375f, 0.99609375f)); _buildable = GetComponentInParent <Constructable>(); if (_prefabId == null) { _prefabId = GetPrefabID(); } SystemLightManager = gameObject.EnsureComponent <SystemLightManager>(); SystemLightManager.Initialize(gameObject); PowerManager = gameObject.EnsureComponent <FCSPowerManager>(); if (PowerManager == null) { QuickLogger.Error("Power Manager was not found."); } else { PowerManager.Initialize(this); } AnimationManager = gameObject.EnsureComponent <FCSPowerStorageAnimationManager>(); if (AnimationManager == null) { QuickLogger.Error("Animation Manager was not found."); } else { AnimationManager.Initialize(this); if (Manager == null) { QuickLogger.Error("Manager is null cannot set Base Drain Protection!"); } else { AnimationManager.SetBoolHash(BaseDrainHash, GetBaseDrainProtection()); } } if (Display == null) { Display = gameObject.GetComponent <FCSPowerStorageDisplay>(); } Display.Setup(this); _initialized = true; }
public static void tryProcessSpecial(PrefabIdentifier prefabID) { if (debrisSpecial.TryGetValue(prefabID.ClassId, out Action <GameObject> processFunc)) { $"Special processing {prefabID.gameObject.name}".logDbg(); processFunc(prefabID.gameObject); prefabID.gameObject.ensureComponent <DebrisProcessed>(); } }
internal string GetPrefabIDString() { if (_prefabId == null) { _prefabId = GetPrefabID(); } return(_prefabId.Id); }
public void InitializeBase(FCSController mono, IFCSStorage storage, FCSPowerManager powerManager, PrefabIdentifier prefabIdentifier) { _mono = mono; _storage = storage; _powerManager = powerManager; _prefabId = prefabIdentifier; _isBase = true; }
private GameObject PreparePrefab(GameObject thisPrefab) { if (thisPrefab == null) { Log.LogError("ModifyInstantiatedPrefab called with null prefab!"); return(null); } var obj = GameObject.Instantiate(thisPrefab); MeshRenderer[] meshRenderers = obj.GetAllComponentsInChildren <MeshRenderer>(); SkinnedMeshRenderer[] skinnedMeshRenderers = obj.GetAllComponentsInChildren <SkinnedMeshRenderer>(); Color powerGlideColour = PowerglideBehaviour.PowerGlideColour; foreach (MeshRenderer mr in meshRenderers) { // MeshRenderers have the third-person mesh, apparently? if (mr.name.Contains("SeaGlide_01_damaged")) { mr.material.color = powerGlideColour; } } foreach (SkinnedMeshRenderer smr in skinnedMeshRenderers) { if (smr.name.Contains("SeaGlide_geo")) { smr.material.color = powerGlideColour; } } PrefabIdentifier prefabIdentifier = obj.EnsureComponent <PrefabIdentifier>(); prefabIdentifier.ClassId = this.ClassID; obj.EnsureComponent <LargeWorldEntity>().cellLevel = LargeWorldEntity.CellLevel.VeryFar; obj.EnsureComponent <TechTag>().type = this.TechType; Pickupable pickupable = obj.EnsureComponent <Pickupable>(); pickupable.isPickupable = false; ResourceTracker resourceTracker = obj.EnsureComponent <ResourceTracker>(); resourceTracker.prefabIdentifier = prefabIdentifier; typeof(ResourceTracker).GetField("techType", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(resourceTracker, this.TechType); //resourceTracker.techType = this.TechType; resourceTracker.overrideTechType = TechType.Fragment; resourceTracker.techType = Main.GetModTechType("PowerglideFragment"); resourceTracker.rb = obj.GetComponent <Rigidbody>(); resourceTracker.pickupable = pickupable; ModPrefabCache.AddPrefab(obj, false); // This doesn't actually do any caching, but it does disable the prefab without "disabling" it - the prefab doesn't show up in the world [as with SetActive(false)] // but it can still be instantiated. [unlike with SetActive(false)] return(obj); }
public override GameObject GetGameObject() { if (processedPrefab is null) { GameObject prefab = Main.assetBundle.LoadAsset <GameObject>("TechPistol.prefab"); GameObject gameObject = GameObject.Instantiate(prefab); gameObject.SetActive(false); prefab.SetActive(false); gameObject.transform.localEulerAngles = new Vector3(90f, 0f, 0f); gameObject.transform.localPosition += Vector3.up * 2; Renderer[] componentsInChildren = gameObject.transform.Find("HandGun").gameObject.GetComponentsInChildren <Renderer>(); foreach (Renderer renderer in componentsInChildren) { if (renderer.name.StartsWith("Gun") || renderer.name.StartsWith("Target")) { Texture emissionMap = renderer.material.GetTexture("_EmissionMap"); Texture specMap = renderer.material.GetTexture("_MetallicGlossMap"); renderer.material.shader = Shader.Find("MarmosetUBER"); renderer.material.EnableKeyword("MARMO_EMISSION"); renderer.material.EnableKeyword("MARMO_SPECMAP"); renderer.material.SetTexture(ShaderPropertyID._Illum, emissionMap); renderer.material.SetTexture(ShaderPropertyID._SpecTex, specMap); renderer.material.SetColor("_GlowColor", new Color(1f, 1f, 1f)); renderer.material.SetFloat(ShaderPropertyID._GlowStrength, 1f); renderer.material.SetFloat(ShaderPropertyID._GlowStrengthNight, 1f); } } GameObject.Destroy(gameObject.transform.Find(PistolBehaviour.GunMain + "/ModeChange")?.gameObject); GameObject.Destroy(gameObject.transform.Find(PistolBehaviour.Point)?.gameObject); GameObject.Destroy(gameObject.GetComponent <PistolBehaviour>()); GameObject.Destroy(gameObject.GetComponent <EnergyMixin>()); GameObject.Destroy(gameObject.GetComponent <VFXFabricating>()); PrefabIdentifier prefabIdentifier = gameObject.GetComponent <PrefabIdentifier>(); prefabIdentifier.ClassId = this.ClassID; gameObject.GetComponent <LargeWorldEntity>().cellLevel = LargeWorldEntity.CellLevel.VeryFar; gameObject.GetComponent <TechTag>().type = this.TechType; Pickupable pickupable = gameObject.GetComponent <Pickupable>(); pickupable.isPickupable = false; ResourceTracker resourceTracker = gameObject.EnsureComponent <ResourceTracker>(); resourceTracker.prefabIdentifier = prefabIdentifier; resourceTracker.techType = this.TechType; resourceTracker.overrideTechType = TechType.Fragment; resourceTracker.rb = gameObject.GetComponent <Rigidbody>(); resourceTracker.pickupable = pickupable; processedPrefab = gameObject; } return(processedPrefab); }
private void Init() { spotLight = GetComponent <BaseSpotLight>(); identifier = GetComponent <PrefabIdentifier>(); id = identifier.Id; OnProtoDeserialize(null); initialized = true; }
public void OnProtoDeserialize(ProtobufSerializer serializer) { PrefabIdentifier id = GetComponentInParent <PrefabIdentifier>(); if (id == null || this._storageContainer == null) { return; } #if DEBUG_CARGO_CRATES Logger.Log("DEBUG: Deserialize(): PrefabID=[" + id.Id + "]"); #endif string filePath = Path.Combine(FilesHelper.GetSaveFolderPath(), "cargocrate_" + id.Id + ".txt"); if (File.Exists(filePath)) { string tmpSize = File.ReadAllText(filePath); string[] sizes = tmpSize.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (sizes.Length == 2) { GameObject model = this.gameObject.FindChild("cargobox01_damaged"); if (model == null) { if ((model = this.gameObject.FindChild("cargobox01a")) == null) { model = this.gameObject.FindChild("cargobox01b"); } } if (model == null) { return; } BoxCollider collider = this.gameObject.GetComponent <BoxCollider>(); float size = float.Parse(sizes[0], CultureInfo.InvariantCulture.NumberFormat); model.transform.localScale = new Vector3(size, size, size); string[] colliderSizes = sizes[1].Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (colliderSizes.Length == 3) { float colliderSizeX = float.Parse(colliderSizes[0], CultureInfo.InvariantCulture.NumberFormat); float colliderSizeY = float.Parse(colliderSizes[1], CultureInfo.InvariantCulture.NumberFormat); float colliderSizeZ = float.Parse(colliderSizes[2], CultureInfo.InvariantCulture.NumberFormat); collider.size = new Vector3(colliderSizeX, colliderSizeY, colliderSizeZ); } else // Backward compatibility { float colliderSize; if (float.TryParse(sizes[1], out colliderSize)) { collider.size = new Vector3(colliderSize * 0.4583f, colliderSize, colliderSize * 0.5555f); } } } } }
public static bool OnHandClick_Prefix(GrownPlant __instance, GUIHand hand) { if (__instance.seed != null && __instance.seed.gameObject != null) { PrefabIdentifier prefabID = __instance.seed.gameObject.GetComponent <PrefabIdentifier>(); if (prefabID == null) { return(true); } if (prefabID.ClassId == "MarbleMelonTiny") { PlantGenericController controllerA = __instance.gameObject.GetComponent <PlantGenericController>(); if (controllerA == null) { controllerA = __instance.seed.gameObject.GetComponent <PlantGenericController>(); } if (controllerA != null && controllerA._progress >= 1.0f) { if (__instance.seed.currentPlanter != null && Inventory.Get().HasRoomFor(1, 1)) { __instance.seed.currentPlanter.RemoveItem(__instance.seed); if (global::Utils.GetSubRoot() != null) { __instance.seed.pickupable.destroyOnDeath = false; } SkyEnvironmentChanged.Send(__instance.seed.pickupable.gameObject, Player.main.GetSkyEnvironment()); UnityEngine.Object.Destroy(__instance.seed.pickupable.gameObject); CraftData.AddToInventorySync(CrafterLogicFixer.MarbleMelonTinyFruit, 1, false, false); hand.player.PlayGrab(); } } return(false); } else if (prefabID.ClassId == "MarbleMelonTinyFruit") { if (__instance.seed.currentPlanter != null && __instance.seed.pickupable != null && Inventory.Get().HasRoomFor(__instance.seed.pickupable)) { PlantGenericController controllerA = __instance.gameObject.GetComponent <PlantGenericController>(); if (controllerA == null) { controllerA = __instance.seed.gameObject.GetComponent <PlantGenericController>(); } if (controllerA != null && controllerA._progress >= 1.0f) { __instance.seed.currentPlanter.RemoveItem(__instance.seed); Inventory.Get().Pickup(__instance.seed.pickupable, false); hand.player.PlayGrab(); } } return(false); } } return(true); }
internal static void Register() { var model = _prefab.FindChild("model"); SkyApplier skyApplier = _prefab.AddComponent <SkyApplier>(); skyApplier.renderers = model.GetComponentsInChildren <MeshRenderer>(); skyApplier.anchorSky = Skies.Auto; // Add large world entity ALLOWS YOU TO SAVE ON TERRAIN var lwe = _prefab.AddComponent <LargeWorldEntity>(); lwe.cellLevel = LargeWorldEntity.CellLevel.Far; //========== Allows the building animation and material colors ==========// // Add constructible var constructable = _prefab.AddComponent <Constructable>(); constructable.allowedOutside = true; constructable.forceUpright = true; constructable.placeMaxDistance = 7f; constructable.placeMinDistance = 5f; constructable.placeDefaultDistance = 6f; constructable.model = model; constructable.techType = Singleton.TechType; PrefabIdentifier prefabID = _prefab.AddComponent <PrefabIdentifier>(); prefabID.ClassId = Singleton.ClassID; Rigidbody component = _prefab.EnsureComponent <Rigidbody>(); component.mass = 400f; component.angularDrag = 1f; component.drag = 1f; component.isKinematic = false; component.freezeRotation = false; component.detectCollisions = true; component.useGravity = false; _prefab.AddComponent <Stabilizer>().uprightAccelerationStiffness = 0.3f; _prefab.AddComponent <TechTag>().type = Singleton.TechType; _prefab.AddComponent <FMOD_CustomLoopingEmitter>(); _prefab.AddComponent <GaspodManager>(); _prefab.AddComponent <AnimationManager>(); _prefab.AddComponent <GaspodCollectorController>(); var wf = _prefab.AddComponent <WorldForces>(); wf.aboveWaterGravity = 9.81f; wf.underwaterDrag = 2f; wf.handleGravity = true; wf.handleDrag = true; }
public override IEnumerator GetGameObjectAsync(IOut <GameObject> gameObject) { if (processedPrefab == null) { CoroutineTask <GameObject> task = CraftData.GetPrefabForTechTypeAsync(TechType.SeaglideFragment); yield return(task); GameObject prefab = GameObject.Instantiate(task.GetResult()); MeshRenderer[] meshRenderers = prefab.GetAllComponentsInChildren <MeshRenderer>(); SkinnedMeshRenderer[] skinnedMeshRenderers = prefab.GetAllComponentsInChildren <SkinnedMeshRenderer>(); Color powerGlideColour = new Color(PowerglideEquipable.PowerglideColourR, PowerglideEquipable.PowerglideColourG, PowerglideEquipable.PowerglideColourB); foreach (MeshRenderer mr in meshRenderers) { // MeshRenderers have the third-person mesh, apparently? if (mr.name.Contains("SeaGlide_01_damaged")) { mr.material.color = powerGlideColour; } } foreach (SkinnedMeshRenderer smr in skinnedMeshRenderers) { if (smr.name.Contains("SeaGlide_geo")) { smr.material.color = powerGlideColour; } } PrefabIdentifier prefabIdentifier = prefab.GetComponent <PrefabIdentifier>(); prefabIdentifier.ClassId = this.ClassID; prefab.GetComponent <LargeWorldEntity>().cellLevel = LargeWorldEntity.CellLevel.VeryFar; prefab.EnsureComponent <TechTag>().type = this.TechType; Pickupable pickupable = prefab.GetComponent <Pickupable>(); pickupable.isPickupable = false; ResourceTracker resourceTracker = prefab.EnsureComponent <ResourceTracker>(); resourceTracker.prefabIdentifier = prefabIdentifier; typeof(ResourceTracker).GetField("techType", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(resourceTracker, this.TechType); //resourceTracker.techType = this.TechType; resourceTracker.overrideTechType = TechType.Fragment; resourceTracker.rb = prefab.GetComponent <Rigidbody>(); resourceTracker.pickupable = pickupable; prefab.SetActive(true); processedPrefab = prefab; ModPrefabCache.AddPrefab(processedPrefab, false); // This doesn't actually do any caching, but it does disable the prefab without "disabling" it - the prefab doesn't show up in the world [as with SetActive(false)] // but it can still be instantiated. [unlike with SetActive(false)] } gameObject.Set(processedPrefab); }
private void OnTriggerExit(Collider other) { if (this.IsEnemy(other)) { this.preventHole = false; this.CheckCanPlace(); return; } PrefabIdentifier componentInParent = other.GetComponentInParent<PrefabIdentifier>(); this.TryRemoveTarget(componentInParent, other); }
public CyBioReactorMini(ref BaseBioReactor bioReactor) { BioReactor = bioReactor; PrefabIdentifier prefabIdentifier = bioReactor.GetComponentInParent <PrefabIdentifier>() ?? bioReactor.GetComponent <PrefabIdentifier>(); string id = prefabIdentifier.Id; QuickLogger.Debug($"CyBioReactorMini PrefabIdentifier: {id}"); SaveData = new CyBioReactorSaveData(id); }
private void Init() { geo = GetComponentInParent <BaseFiltrationMachineGeometry>(); machine = (FiltrationMachine)GetModuleMethod.Invoke(geo, new object[] { }); identifier = machine.GetComponent <PrefabIdentifier>(); id = identifier.Id; toggle = machine.GetComponent <FiltrationMachineToggle>(); initialized = true; }
public void Init() { isOn = true; techLight = GetComponent <TechLight>(); identifier = GetComponentInParent <PrefabIdentifier>(); id = identifier.Id; OnProtoDeserialize(null); initialized = true; }
public GameObject GetPrefab(PrefabIdentifier identifier) { //Debug.Log("GetPrefab "+identifier); return PrefabsMap[identifier]; }