public void Awake() { if (m_forceDisableInit) { Object.Destroy(this); return; } if (!originalPiece) { InvalidPlanPiece(); return; } //logger.LogInfo("Prefab loaded for " + name + " -> " + originalPrefab.name); DisablePiece(gameObject); //logger.LogInfo("PlanPiece awake: " + gameObject.GetInstanceID()); m_wearNTear = GetComponent <WearNTear>(); m_nView = GetComponent <ZNetView>(); if (m_nView.IsOwner()) { m_nView.GetZDO().Set("support", 0f); } m_nView.Register <bool>("Refund", RPC_Refund); m_nView.Register <string, int>("AddResource", RPC_AddResource); m_nView.Register("SpawnPieceAndDestroy", RPC_SpawnPieceAndDestroy); UpdateHoverText(); }
static void Postfix(ZNetView ___m_nview) { if (___m_nview.IsValid()) { ___m_nview.Register <Vector3>(Constants.Z_CallHomeCommand, RPC_CallHome); } }
public void Awake() { if (!originalPiece) { InvalidPlanPiece(); return; } m_wearNTear = GetComponent <WearNTear>(); m_nView = GetComponent <ZNetView>(); if (m_nView.IsOwner()) { m_nView.GetZDO().Set("support", 0f); } m_nView.Register <bool>("Refund", RPC_Refund); m_nView.Register <string, int>("AddResource", RPC_AddResource); m_nView.Register("SpawnPieceAndDestroy", RPC_SpawnPieceAndDestroy); UpdateHoverText(); UpdateTextures(); }
public void Awake() { if (m_spaceMask == 0) { m_spaceMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece", "piece_nonsolid"); } ScanCultivator(); m_nview = GetComponent <ZNetView>(); WearNTear wearNTear = GetComponent <WearNTear>(); wearNTear.m_onDestroyed = (Action)Delegate.Combine(wearNTear.m_onDestroyed, new Action(OnDestroyed)); m_nview.Register <string, int>("AddSeed", RPC_AddSeed); m_nview.Register <string>("Restrict", RPC_Restrict); InvokeRepeating("UpdateSeedTotem", 1f, 1f); InvokeRepeating("DisperseSeeds", 1f, configDispersionTime.Value); UpdateMaterials(false); UpdateGlowColor(this); }
public void Awake() { m_nview = GetComponent <ZNetView>(); m_nview.Register <string>("AddCore", RPC_AddCore); m_nview.Register("DropCores", RPC_DropCores); InvokeRepeating("UpdateStatus", 1f, 1f); smelter = GetComponent <Smelter>(); if (!smelter) { Debug.LogError("No smelter attached?! @ " + base.transform.position); } else { original_m_secPerProduct = smelter.m_secPerProduct; } if (m_nview.IsValid() && m_nview.IsOwner()) { MigrateKeys(); UpdateSmelterValues(); } }
static void Postfix(Character __instance, ref ZNetView ___m_nview) { if (MobConfigManager.IsControllableMob(__instance.name)) { string uniqueId = GetOrCreateUniqueId(___m_nview); var mobInfo = MobConfigManager.GetMobConfig(__instance.name); Tameable tameable = GetOrAddTameable(__instance); tameable.m_tamingTime = mobInfo.TamingTime; tameable.m_commandable = true; AddVisualEquipmentCapability(__instance); ___m_nview.Register <string, string>(Constants.Z_UpdateCharacterHUD, RPC_UpdateCharacterName); var ai = __instance.GetBaseAI() as MonsterAI; if (__instance.IsTamed()) { try { MobManager.RegisterMob(__instance, uniqueId, mobInfo.AIType, mobInfo.AIConfig); } catch (ArgumentException e) { Debug.LogError($"Failed to register Mob AI ({mobInfo.AIType}). {e.Message}"); return; } __instance.m_faction = Character.Faction.Players; ai.m_consumeItems.Clear(); ai.m_consumeItems.AddRange(mobInfo.PostTameConsumables); ai.m_consumeSearchRange = mobInfo.AIConfig.Awareness * 5; ai.m_randomMoveRange = mobInfo.AIConfig.Mobility * 2; ai.m_randomMoveInterval = 15 - mobInfo.AIConfig.Mobility; string givenName = ___m_nview?.GetZDO()?.GetString(Constants.Z_GivenName); if (!string.IsNullOrEmpty(givenName)) { __instance.m_name = givenName; } } else { tameable.m_fedDuration = mobInfo.PreTameFeedDuration; ai.m_consumeItems.Clear(); ai.m_consumeItems.AddRange(mobInfo.PreTameConsumables); } } }
public void Register() { _zNetView.Register("LockContainersRequest", new Action <long, long, bool>(RPC_LockContainersRequest)); _zNetView.Register("LockContainersResponse", new Action <long, long, bool, bool>(RPC_LockContainersResponse)); }
static void Postfix(Character __instance, ref ZNetView ___m_nview) { if (__instance.name.Contains("Greyling")) { //Debug.Log($"A {__instance.name} just spawned!"); var uniqueId = ___m_nview.GetZDO().GetString(Constants.Z_CharacterId); if (string.IsNullOrEmpty(uniqueId)) { uniqueId = System.Guid.NewGuid().ToString(); ___m_nview.GetZDO().Set(Constants.Z_CharacterId, uniqueId); } var tameable = __instance.gameObject.GetComponent <Tameable>(); if (tameable == null) { tameable = __instance.gameObject.AddComponent <Tameable>(); } tameable.m_fedDuration = (float)GreylingsConfig.FeedDuration.Value; tameable.m_tamingTime = (float)GreylingsConfig.TamingTime.Value; tameable.m_commandable = true; var visEquipment = __instance.gameObject.GetComponent <VisEquipment>(); if (visEquipment == null) { __instance.gameObject.AddComponent <VisEquipment>(); visEquipment = __instance.gameObject.GetComponent <VisEquipment>(); //_NetSceneRoot/Greyling(Clone)/Visual/Armature.001/root/spine1/spine2/spine3/r_shoulder/r_arm1/r_arm2/r_hand var rightHand = __instance.gameObject.GetComponentsInChildren <Transform>().Where(c => c.name == "r_hand").Single(); visEquipment.m_rightHand = rightHand; } if (m_allNamedMobs.ContainsKey(uniqueId)) { m_allNamedMobs[uniqueId] = __instance.GetInstanceID(); } else { m_allNamedMobs.Add(uniqueId, __instance.GetInstanceID()); } ___m_nview.Register <string, string>(Constants.Z_UpdateCharacterHUD, RPC_UpdateCharacterName); var ai = __instance.GetBaseAI() as MonsterAI; if (__instance.IsTamed()) { ai.m_consumeItems.Clear(); ai.m_consumeItems.Add(ObjectDB.instance.GetAllItems(ItemDrop.ItemData.ItemType.Material, "Resin").FirstOrDefault()); ai.m_randomMoveRange = 5; ai.m_consumeSearchRange = 50; string givenName = ___m_nview?.GetZDO()?.GetString(Constants.Z_GivenName); if (!string.IsNullOrEmpty(givenName)) { __instance.m_name = givenName; } } else { ai.m_consumeItems.Clear(); var tamingItemNames = GreylingsConfig.TamingItemList.Value.Split(','); foreach (string consumeItem in tamingItemNames) { ai.m_consumeItems.Add(ObjectDB.instance.GetAllItems(ItemDrop.ItemData.ItemType.Material, consumeItem).FirstOrDefault()); } } } }