Beispiel #1
0
        public static void DeleteTMod(TerrainModifier modifier)
        {
            ZNetView znview = modifier.gameObject.GetComponent <ZNetView>();

            if (!znview || znview.GetZDO() == null)
            {
                return;
            }
            bool has_copy = false;

            foreach (ZDO item in zdos_to_save)
            {
                if (item.m_uid == znview.GetZDO().m_uid)
                {
                    has_copy = true;
                    break;
                }
            }
            if (!has_copy)
            {
                zdos_to_save.Add(znview.GetZDO().Clone());
            }
            modifier.enabled = false;
            znview.ClaimOwnership();
            if (!new string[3] {
                "mud_road(Clone)", "digg(Clone)", "path(Clone)"
            }.Contains(modifier.name))
            {
                Debug.LogWarning("Deleting " + modifier.name);
            }
            Debug.Log("Deleting " + modifier.name);
            ZNetScene.instance.Destroy(modifier.gameObject);
        }
Beispiel #2
0
        private void Awake()
        {
            //add
            m_nview = GetComponent <ZNetView>();
            if (m_nview.GetZDO() == null)
            {
                DBG.blogWarning("Mark Report zdo null");
                return;
            }
            if (m_nview.GetZDO().GetBool("LocMarkUsed", false))
            {
                MarkList.Remove(ID);
                Destroy(this);
                return;
            }
            else
            {
                ID = ZoneSystem.instance.GetZone(transform.position).Pak();
                if (MarkList.ContainsKey(ID))
                {
                    DubList.Add(ID, this);
                }
                else
                {
                    MarkList.Add(ID, this);
                }

                DBG.blogInfo("locmark placed at zone : " + ID);
            }
        }
Beispiel #3
0
            static void Postfix(CookingStation __instance, ZNetView ___m_nview)
            {
                if (!modEnabled.Value || !___m_nview.IsValid() || !___m_nview.IsOwner() || !EffectArea.IsPointInsideArea(__instance.transform.position, EffectArea.Type.Burning, 0.25f))
                {
                    return;
                }
                for (int i = 0; i < __instance.m_slots.Length; i++)
                {
                    string itemName = ___m_nview.GetZDO().GetString("slot" + i, "");

                    float num = ___m_nview.GetZDO().GetFloat("slot" + i, 0f);
                    if (itemName != "" && itemName != __instance.m_overCookedItem.name && itemName != null)
                    {
                        CookingStation.ItemConversion itemConversion = Traverse.Create(__instance).Method("GetItemConversion", new object[] { itemName }).GetValue <CookingStation.ItemConversion>();
                        if (num > itemConversion.m_cookTime && itemName == itemConversion.m_to.name)
                        {
                            if (autoPop.Value)
                            {
                                Traverse.Create(__instance).Method("SpawnItem", new object[] { itemName }).GetValue();
                                ___m_nview.GetZDO().Set("slot" + i, "");
                                ___m_nview.GetZDO().Set("slot" + i, 0f);
                                ___m_nview.InvokeRPC(ZNetView.Everybody, "SetSlotVisual", new object[] { i, "" });
                            }
                            else if (preventBurning.Value)
                            {
                                ___m_nview.GetZDO().Set("slot" + i, itemConversion.m_cookTime);
                            }
                        }
                    }
                }
            }
Beispiel #4
0
            public static void Prefix(float v, Player __instance, ZNetView ___m_nview)
            {
                try
                {
                    var progress = ___m_nview.GetZDO().GetFloat("hearty_progress", 0f);
                    //adjust the amount by the multiplier
                    progress += v;

                    if (progress > skillGainIncrement.Value)
                    {
                        var ratio = progress / __instance.GetMaxStamina();
                        __instance.RaiseSkill((Skills.SkillType)SKILL_TYPE, ratio * configSkillIncrease.Value);
                        ___m_nview.GetZDO().Set("hearty_progress", 0f);
                    }
                    else
                    {
                        ___m_nview.GetZDO().Set("hearty_progress", progress);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("[Zomb Hearty] Failed to augement hearty skill.");
                    Debug.LogError(e.ToString());
                }
            }
        private void Start()
        {
            if (m_piece.IsPlacedByPlayer())
            {
                // if ZDO.getbool wasPlaced == true
                // Skip over specific initializer stuff
                // else
                // ZDO.set wasPlaced == true;
                // do specific initializer stuffs


                Jotunn.Logger.LogDebug("Doing stuff to expander that was placed by a player");


                m_nview.SetPersistent(true);


                m_nview.GetZDO().Set("isActive", m_nview.GetZDO().GetBool("isActive", false));


                /*
                 * // if this object was loaded from save, and it was active
                 * // i
                 */
            }
        }
Beispiel #6
0
            static void Postfix(Container __instance, ZNetView ___m_nview)
            {
                if (!isOn.Value || ___m_nview == null || ___m_nview.GetZDO() == null)
                {
                    return;
                }

                Vector3 position = __instance.transform.position + Vector3.up;

                foreach (Collider collider in Physics.OverlapSphere(position, ContainerRange(__instance), LayerMask.GetMask(new string[] { "item" })))
                {
                    if (collider?.attachedRigidbody)
                    {
                        ItemDrop item = collider.attachedRigidbody.GetComponent <ItemDrop>();
                        //Dbgl($"nearby item name: {item.m_itemData.m_dropPrefab.name}");

                        if (item?.GetComponent <ZNetView>()?.IsValid() != true || !item.GetComponent <ZNetView>().IsOwner())
                        {
                            continue;
                        }

                        if (DisallowItem(__instance, item.m_itemData))
                        {
                            continue;
                        }

                        Dbgl($"auto storing {item.m_itemData.m_dropPrefab.name} from ground");


                        while (item.m_itemData.m_stack > 1 && __instance.GetInventory().CanAddItem(item.m_itemData, 1))
                        {
                            item.m_itemData.m_stack--;
                            ItemDrop.ItemData newItem = item.m_itemData.Clone();
                            newItem.m_stack = 1;
                            __instance.GetInventory().AddItem(newItem);
                            Traverse.Create(item).Method("Save").GetValue();
                            typeof(Container).GetMethod("Save", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { });
                            typeof(Inventory).GetMethod("Changed", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance.GetInventory(), new object[] { });
                        }

                        if (item.m_itemData.m_stack == 1 && __instance.GetInventory().CanAddItem(item.m_itemData, 1))
                        {
                            ItemDrop.ItemData newItem = item.m_itemData.Clone();
                            item.m_itemData.m_stack = 0;
                            Traverse.Create(item).Method("Save").GetValue();
                            if (___m_nview.GetZDO() == null)
                            {
                                DestroyImmediate(item.gameObject);
                            }
                            else
                            {
                                ZNetScene.instance.Destroy(item.gameObject);
                            }
                            __instance.GetInventory().AddItem(newItem);
                            typeof(Container).GetMethod("Save", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { });
                            typeof(Inventory).GetMethod("Changed", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance.GetInventory(), new object[] { });
                        }
                    }
                }
            }
Beispiel #7
0
 static void Prefix(ZNetView ___m_nview)
 {
     if (___m_nview)
     {
         if (___m_nview.GetPrefabName() == "portal_wood")
         {
             if (ZNet.instance.IsServer())
             {
                 ZDO             temp_zdo  = ___m_nview.GetZDO();
                 Minimap.PinData temp_data = Minimap.instance.AddPin(___m_nview.transform.position, portal_pin_type, GetLocalizedString(configPortalNamePrefix.Value) + "unnamed", false, false);
                 tp_list.Add(temp_zdo, temp_data);
                 ZDOMan.instance.ForceSendZDO(temp_zdo.m_uid);
             }
             else
             {
                 ZDO temp_zdo = ___m_nview.GetZDO();
                 var list     = (List <int>)GetInstanceField(ZDOMan.instance, "m_peers");
                 logger.LogWarning("portal placed ");
                 logger.LogWarning("m_peers count: " + list.Count);
                 ZDOMan.instance.ForceSendZDO(temp_zdo.m_uid);
                 //ZRoutedRpc.instance.InvokeRoutedRPC("RequestPortalZDOs", new object[] { new ZPackage() });
             }
         }
     }
 }
 private int GetCoreCount(string coreName)
 {
     if (!this.m_nview.IsValid())
     {
         return(0);
     }
     return(m_nview.GetZDO().GetInt("count_" + coreName));
 }
Beispiel #9
0
        public static void ResetHardcorePlayer(PlayerProfile playerProfile)
        {
            Traverse.Create(Player.m_localPlayer)
            .Field <Skills>("m_skills").Value
            .Clear();

            Player.m_localPlayer.GetKnownTexts().RemoveAll((KeyValuePair <string, string> pair) => { return(pair.Key.StartsWith("<|>")); });

            // Clear out custom EquipmentSlotInventory and QuickSlotInventory, if applicable
            AppDomain       currentDomain = AppDomain.CurrentDomain;
            List <Assembly> assemblies    = new List <Assembly>(currentDomain.GetAssemblies());

            if (assemblies.Find((Assembly assembly) => { return(assembly.GetName().Name == "EquipmentAndQuickSlots"); }) != null)
            {
                Component extendedPlayerData = Player.m_localPlayer.GetComponent("ExtendedPlayerData");
                if (extendedPlayerData)
                {
                    Traverse tExtendedPlayerData = Traverse.Create(extendedPlayerData);
                    tExtendedPlayerData.Field <Inventory>("EquipmentSlotInventory").Value.RemoveAll();
                    tExtendedPlayerData.Field <Inventory>("QuickSlotInventory").Value.RemoveAll();
                }
            }
            // End clear custom inventories

            if (Settings.ClearMapOnDeath.Value)
            {
                // Reset sync data for MapSharingMadeEasy to prevent removal of all shared pins on next sync
                ZNetView nview = Traverse.Create(Player.m_localPlayer).Field <ZNetView>("m_nview").Value;
                if (nview != null)
                {
                    string syncData = nview.GetZDO().GetString("playerSyncData", string.Empty);
                    if (!string.IsNullOrEmpty(syncData))
                    {
                        nview.GetZDO().Set("playerSyncData", string.Empty);
                    }
                }
                // End reset sync data

                Traverse tMinimap                   = Traverse.Create(Minimap.instance);
                List <Minimap.PinData> pins         = tMinimap.Field <List <Minimap.PinData> >("m_pins").Value;
                List <Minimap.PinData> pinsToRemove = new List <Minimap.PinData>();
                foreach (Minimap.PinData pin in pins)
                {
                    if (pin.m_save)
                    {
                        pinsToRemove.Add(pin);
                    }
                }
                foreach (Minimap.PinData pinToRemove in pinsToRemove)
                {
                    Minimap.instance.RemovePin(pinToRemove);
                }

                Minimap.instance.Reset();
                Minimap.instance.SaveMapData();
            }
        }
            static void Postfix(Door __instance, ref string __result, ZNetView ___m_nview)
            {
                if (!modEnabled.Value || ___m_nview.GetZDO() == null || !___m_nview.GetZDO().GetBool("LockedDoor"))
                {
                    return;
                }

                __result = __result.Replace(Localization.instance.Localize(__instance.m_name), string.Format(doorName.Value, GetDoorName(___m_nview.GetZDO().GetString("DoorGUID")), ___m_nview.GetZDO().GetBool("DoorLocked")));
            }
Beispiel #11
0
            public static void Postfix(ref string __result, bool ___m_picked, ZNetView ___m_nview, int ___m_respawnTimeMinutes, Pickable __instance)
            {
                if (___m_picked && ___m_nview.GetZDO() != null)
                {
                    long     @long    = ___m_nview.GetZDO().GetLong("picked_time", 0L);
                    DateTime dateTime = new DateTime(@long);
                    double   mins     = (ZNet.instance.GetTime() - dateTime).TotalMinutes;

                    float factor = Player.m_localPlayer.GetSkillFactor((Skills.SkillType)SKILL_TYPE);
                    int   level  = (int)(factor * 100f);

                    var remainingMinutes = (___m_respawnTimeMinutes - mins);
                    var remainingRatio   = remainingMinutes / (float)___m_respawnTimeMinutes;
                    var color            = "red";
                    var completeCategory = "in a long time";
                    if (remainingRatio < 0)
                    {
                        color            = "blue";
                        completeCategory = "any second now";
                    }
                    else if (remainingRatio < 0.25)
                    {
                        color            = "green";
                        completeCategory = "soon";
                    }
                    else if (remainingRatio < 0.5)
                    {
                        color            = "yellow";
                        completeCategory = "in a while";
                    }
                    if (level >= configDetailedEstimateLevel.Value)
                    {
                        if (remainingMinutes < 0.0)
                        {
                            __result = Localization.instance.Localize(__instance.GetHoverName() + "\n(<color=" + color + "><b>Ready any second now</b></color>)");
                        }
                        else if (remainingMinutes < 1.0)
                        {
                            __result = Localization.instance.Localize(__instance.GetHoverName() + "\n(<color=" + color + "><b>Ready in less than a minute</b></color>)");
                        }
                        else
                        {
                            __result = Localization.instance.Localize(__instance.GetHoverName() + "\n(<color=" + color + "><b>Ready in " + remainingMinutes.ToString("F0") + " min</b></color>)");
                        }
                    }
                    else if (level >= configSimpleEstimateLevel.Value)
                    {
                        __result = Localization.instance.Localize(__instance.GetHoverName() + "\n(<color=" + color + "><b>Ready " + completeCategory + "</b></color>)");
                    }
                    else if (factor > 0.0)
                    {
                        __result = Localization.instance.Localize(__instance.GetHoverName());
                    }
                }
            }
Beispiel #12
0
            private static string GetOrCreateUniqueId(ZNetView ___m_nview)
            {
                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);
                }
                return(uniqueId);
            }
Beispiel #13
0
        public static string GetOrCreateUniqueId(ZNetView nview)
        {
            var uniqueId = nview.GetZDO().GetString(Constants.Z_UniqueId);

            if (string.IsNullOrEmpty(uniqueId))
            {
                uniqueId = System.Guid.NewGuid().ToString();
                nview.GetZDO().Set(Constants.Z_UniqueId, uniqueId);
            }
            return(uniqueId);
        }
Beispiel #14
0
            static void Postfix(TeleportWorld __instance, ref ZNetView ___m_nview, ref bool __result)
            {
                lastPortalInteracted = __instance;
                lastPortalZNetView   = ___m_nview;

                if (!__result)
                {
                    return;
                }

                if (dropdownHolder == null)
                {
                    InitializeDropdownHolder();
                }
                portalList.Clear();
                dropdown.onValueChanged.RemoveAllListeners();
                dropdown.onValueChanged.AddListener(delegate
                {
                    DropdownValueChanged(dropdown);
                });
                dropdown.options.Clear();
                ZDOID thisPortalZDOID = ___m_nview.GetZDO().m_uid;
                // If the portal currently has a target configured, make sure that is the value selected in the dropdown
                // Otherwise, set the dropdown value to 0 (No destination)
                ZDOID targetZDOID = ___m_nview.GetZDO().GetZDOID("target");

                dropdown.options.Add(new Dropdown.OptionData("No destination"));
                var tmpPortalList = new List <ZDO>();

                ZDOMan.instance.GetAllZDOsWithPrefab(Game.instance.m_portalPrefab.name, tmpPortalList);
                // Sort alphabetically by portal tag and exclude self
                portalList = tmpPortalList.OrderBy(zdo => zdo.GetString("tag")).Where(zdo => zdo.m_uid != thisPortalZDOID).ToList();
                int index = 0;

                foreach (ZDO portalZDO in portalList)
                {
                    float distance = Vector3.Distance(__instance.transform.position, portalZDO.GetPosition());
                    if (distance == 0f)
                    {
                        continue;
                    }
                    dropdown.options.Add(new Dropdown.OptionData($"\"{portalZDO.GetString("tag")}\"  --  Distance: " + (int)distance));
                    if (portalZDO.m_uid == targetZDOID)
                    {
                        dropdown.value = index + 1;
                    }
                    index += 1;
                }
                if (targetZDOID == ZDOID.None)
                {
                    dropdown.value = 0;
                }
                dropdownHolder.SetActive(true);
            }
Beispiel #15
0
            public static string UpdateAiStatus(ZNetView nview, string newStatus)
            {
                string currentAiStatus = nview?.GetZDO()?.GetString(Constants.Z_AiStatus);

                if (currentAiStatus != newStatus)
                {
                    string name = nview?.GetZDO()?.GetString(Constants.Z_GivenName);
                    //Debug.Log($"{name}: {newStatus}");
                    nview.GetZDO().Set(Constants.Z_AiStatus, newStatus);
                }
                return(newStatus);
            }
Beispiel #16
0
 public void Update()
 {
     if (m_nView.IsValid())
     {
         bool haveSupport = m_nView.GetZDO().GetFloat("support") >= m_wearNTear.GetMinSupport();
         if (haveSupport != hasSupport)
         {
             hasSupport = haveSupport;
             UpdateTextures();
         }
     }
 }
 private void RPC_LockContainersResponse(long uid, long playerId, bool shouldLock, bool granted)
 {
     Plugin.Log.LogDebug($"Received lock response uid:{uid} pid:{playerId} L:{shouldLock} G:{granted}");
     if (!Player.m_localPlayer || Player.m_localPlayer.GetPlayerID() != playerId)
     {
         return;
     }
     Plugin.Log.LogDebug($"I should handle:{uid} pid:{playerId} L:{shouldLock} G:{granted}");
     if (granted)
     {
         Plugin.Log.LogDebug(
             $"Actual object {_container.GetInventory().GetAllItems().Sum(a => a.m_stack)} total items on {_zNetView.GetZDO().m_uid}");
     }
 }
            static void Postfix(Door __instance, ZNetView ___m_nview)
            {
                if (!modEnabled.Value || !___m_nview.IsValid() || !newDoors.Any() || !newDoors.ContainsKey(__instance.transform.position))
                {
                    return;
                }
                ___m_nview.GetZDO().Set("LockedDoor", true);
                ___m_nview.GetZDO().Set("DoorLocked", true);
                ___m_nview.GetZDO().Set("DoorGUID", newDoors[__instance.transform.position] + "");

                Dbgl($"Set door {newDoors[__instance.transform.position]} as lockable at {__instance.transform.position}");

                newDoors.Remove(__instance.transform.position);
            }
Beispiel #19
0
 public static void Postfix(bool picked, ZNetView ___m_nview, bool ___m_picked, ref PickState __state)
 {
     if (__state.picked == ___m_picked)
     {
         ___m_nview.GetZDO().Set("picked_time", __state.picked_time);
     }
 }
Beispiel #20
0
    // Token: 0x0600087D RID: 2173 RVA: 0x000414C0 File Offset: 0x0003F6C0
    public void Destroy(GameObject go)
    {
        ZNetView component = go.GetComponent <ZNetView>();

        if (component && component.GetZDO() != null)
        {
            ZDO zdo = component.GetZDO();
            component.ResetZDO();
            this.m_instances.Remove(zdo);
            if (zdo.IsOwner())
            {
                ZDOMan.instance.DestroyZDO(zdo);
            }
        }
        UnityEngine.Object.Destroy(go);
    }
Beispiel #21
0
    // Token: 0x06000887 RID: 2183 RVA: 0x00041908 File Offset: 0x0003FB08
    private void RemoveObjects(List <ZDO> currentNearObjects, List <ZDO> currentDistantObjects)
    {
        int frameCount = Time.frameCount;

        foreach (ZDO zdo in currentNearObjects)
        {
            zdo.m_tempRemoveEarmark = frameCount;
        }
        foreach (ZDO zdo2 in currentDistantObjects)
        {
            zdo2.m_tempRemoveEarmark = frameCount;
        }
        this.m_tempRemoved.Clear();
        foreach (ZNetView znetView in this.m_instances.Values)
        {
            if (znetView.GetZDO().m_tempRemoveEarmark != frameCount)
            {
                this.m_tempRemoved.Add(znetView);
            }
        }
        for (int i = 0; i < this.m_tempRemoved.Count; i++)
        {
            ZNetView znetView2 = this.m_tempRemoved[i];
            ZDO      zdo3      = znetView2.GetZDO();
            znetView2.ResetZDO();
            UnityEngine.Object.Destroy(znetView2.gameObject);
            if (!zdo3.m_persistent && zdo3.IsOwner())
            {
                ZDOMan.instance.DestroyZDO(zdo3);
            }
            this.m_instances.Remove(zdo3);
        }
    }
Beispiel #22
0
        public static bool Prefix(Player __instance)
        {
            long         playerID        = __instance.GetPlayerID();
            HardcoreData hardcoreProfile = Hardcore.GetHardcoreDataForProfileID(playerID);

            if (hardcoreProfile != null && hardcoreProfile.isHardcore)
            {
                hardcoreProfile.hasDied = true;

                Traverse tPlayer = Traverse.Create(__instance);
                tPlayer.Field <bool>("m_firstSpawn").Value = true;

                ZNetView nview = tPlayer.Field <ZNetView>("m_nview").Value;
                nview.GetZDO().Set("dead", true);
                nview.InvokeRPC(ZNetView.Everybody, "OnDeath", Array.Empty <object>());
                tPlayer.Method("CreateDeathEffects").GetValue(new object[] { });
                tPlayer.Field <GameObject>("m_visual").Value.SetActive(false);
                tPlayer.Field <List <Player.Food> >("m_foods").Value.Clear();

                __instance.UnequipAllItems();
                __instance.GetInventory().RemoveAll();

                if (Hardcore.Settings.ClearCustomSpawn.Value)
                {
                    Game.instance.GetPlayerProfile().ClearCustomSpawnPoint();
                }
                Game.instance.RequestRespawn(10f);

                Gogan.LogEvent("Game", "Death", "biome: " + __instance.GetCurrentBiome().ToString(), 0L);

                return(false);
            }

            return(true);
        }
Beispiel #23
0
        private void Awake()
        {
            m_nview     = gameObject.GetComponent <ZNetView>();
            m_container = gameObject.GetComponent <Container>();
            var zdo = m_nview.GetZDO();

            if (Placing)
            {
                zdo.Set("QuestID", m_id);
                zdo.Set("QuestSphy", m_sphy);
                zdo.Set("QuestOwener", m_ownerName);
                return;
            }
            else
            {
                m_id        = zdo.GetString("QuestID", "public");
                m_sphy      = zdo.GetBool("QuestSphy", true);
                m_ownerName = zdo.GetString("QuestOwener", "public");
            }
            if (!m_sphy)
            {
                DestroyImmediate(this.GetComponent <StaticPhysics>());
            }

            /*          if (ZNet.instance.IsServer() && ZNet.instance.IsDedicated())
             *                      {
             *                              Destroy(gameObject);
             *                      } */
        }
Beispiel #24
0
        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();
        }
Beispiel #25
0
            public override void OnHit(GameObject gameObject)
            {
                var plant = gameObject.GetComponent <Plant>();

                if (plant != null)
                {
                    ZNetView plantView = (ZNetView)typeof(Plant).GetField("m_nview", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(plant);
                    if (plantView.GetZDO() != null && plantView.IsOwner())
                    {
                        var currentPlantTime = new DateTime(plantView.GetZDO().GetLong("plantTime", ZNet.instance.GetTime().Ticks));
                        var newPlantTime     = currentPlantTime.AddSeconds(-m_hitInterval * m_accelerationFactor);
                        plantView.GetZDO().Set("plantTime", newPlantTime.Ticks);
                        //Debug.Log($"Accelerated plant growth from {currentPlantTime} to {newPlantTime}");
                    }
                }
            }
Beispiel #26
0
        public static void Postfix(ref Character __instance, ref ZNetView ___m_nview)
        {
            var zdo = ___m_nview.GetZDO();

            if (zdo == null)
            {
                return;
            }

            var customName  = zdo.GetString($"{Plugin.GUID}-name");
            var customTamed = zdo.GetBool($"{Plugin.GUID}-tamed");

            if (customName.Length > 0)
            {
                __instance.m_name = customName;
            }

            if (customTamed)
            {
                //Log.Info($"Add tamed character -> {customName}");

                var humanoid = __instance.GetComponent <Humanoid>();
                humanoid.m_faction = Character.Faction.Players;

                tamedCharacters.Add(__instance);
                Prefab.SetTameable(___m_nview, __instance.gameObject);
                __instance.m_name = Prefab.GetTamedName(customName, true);
            }
        }
            public static IEnumerator AutoCloseEnumerator(Door __instance, ZNetView ___m_nview)
            {
                while (true)
                {
                    // 一定時間待機
                    yield return(new WaitForSeconds(0.2f));

                    if (!toggleSwitch) // トグルスイッチでMODが無効化されている
                    {
                        coroutinePairs.Remove(___m_nview.GetHashCode());
                        yield break;
                    }

                    // ドア種別ごとの設定値
                    String doorName        = ___m_nview.GetPrefabName();
                    float  distanceSetting = Utils.GetSettingRangeByDoor(doorName, false);

                    // プレイヤーとの距離を取得し、指定された範囲より離れているときはドアを閉じる
                    float distance = Utils.GetPlayerDistance(__instance.m_doorObject);
                    if (distance > distanceSetting)
                    {
                        yield return(new WaitForSeconds(waitForDoorToCloseSeconds.Value));

                        ___m_nview.GetZDO().Set("state", 0);
                        coroutinePairs.Remove(___m_nview.GetHashCode());
                        yield break;
                    }
                }
            }
Beispiel #28
0
 static void Postfix(Bed __instance, ref string __result, ZNetView ___m_nview)
 {
     if (__instance.IsMine() && (___m_nview.GetZDO().GetLong("owner", 0L) != 0) || Traverse.Create(__instance).Method("IsCurrent").GetValue <bool>())
     {
         __result += Localization.instance.Localize($"\n[<color=yellow><b>P</b></color>] Set hearthstone");
     }
 }
Beispiel #29
0
 private static void Postfix(Fireplace __instance, ref ZNetView ___m_nview)
 {
     if (Configuration.Current.Fireplace.IsEnabled)
     {
         if (Configuration.Current.Fireplace.OnlyTorches)
         {
             if (__instance.GetHoverText().Contains("torch") || __instance.GetHoverText().Contains("Scounce") || __instance.GetHoverText().Contains("brazier"))
             {
                 ___m_nview.GetZDO().Set("fuel", 1f);
             }
         }
         else
         {
             ___m_nview.GetZDO().Set("fuel", 3f);
         }
     }
 }
            static bool Prefix(Door __instance, ZNetView ___m_nview, bool __result, Humanoid character)
            {
                if (!modEnabled.Value || ___m_nview.GetZDO() == null || !(character is Player) || !___m_nview.GetZDO().GetBool("LockedDoor"))
                {
                    return(true);
                }

                string guid = ___m_nview.GetZDO().GetString("DoorGUID");

                Dbgl($"trying to open door {___m_nview.GetZDO().GetString("DoorGUID")}");
                if (AedenthornUtils.CheckKeyHeld(modKey.Value) && (character as Player).GetInventory().GetAllItems().Exists(i => i.m_crafterName == guid))
                {
                    ___m_nview.GetZDO().Set("DoorLocked", !___m_nview.GetZDO().GetBool("DoorLocked"));
                    __result = true;
                    character.Message(MessageHud.MessageType.Center, string.Format(lockedMessage.Value, ___m_nview.GetZDO().GetBool("DoorLocked")), 0, null);

                    Dbgl($"Door locked: {___m_nview.GetZDO().GetBool("DoorLocked")}");
                    return(false);
                }
                else if (AedenthornUtils.CheckKeyHeld(renameModKey.Value) && (character as Player).GetInventory().GetAllItems().Exists(i => i.m_crafterName == guid))
                {
                    __result = true;

                    RenameDoor(guid);

                    Dbgl($"Door name set to : {___m_nview.GetZDO().GetBool("DoorLocked")}");
                    return(false);
                }
                else if (___m_nview.GetZDO().GetBool("DoorLocked") && (needKeyToClose.Value || ___m_nview.GetZDO().GetInt("state", 0) == 0))
                {
                    Dbgl($"Trying to open door {___m_nview.GetZDO().GetString("DoorGUID")} {(character as Player).GetInventory().GetAllItems().Find(i => i.m_crafterName == ___m_nview.GetZDO().GetString("DoorGUID"))?.m_crafterName}");

                    if (!(character as Player).GetInventory().GetAllItems().Exists(i => i.m_crafterName == ___m_nview.GetZDO().GetString("DoorGUID")))
                    {
                        __instance.m_lockedEffects.Create(__instance.transform.position, __instance.transform.rotation, null, 1f);
                        character.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_door_needkey", new string[]
                        {
                            GetDoorName(guid)
                        }), 0, null);
                        __result = true;
                        Dbgl($"player doesn't have key for {__instance.transform.position}");
                        return(false);
                    }
                    else
                    {
                        Dbgl($"player has key for {__instance.transform.position}");
                    }
                }

                return(true);
            }