Example #1
0
        internal void PartOfBlueprint(ZDOID blueprintID, PieceEntry entry)
        {
            ZDO pieceZDO = m_nView.GetZDO();

            pieceZDO.Set(zdoBlueprintID, blueprintID);
            pieceZDO.Set(zdoAdditionalInfo, entry.additionalInfo);
        }
Example #2
0
            public void equip(ItemDrop.ItemData item)
            {
                zdo.Set(zdoVar, item.m_dropPrefab.name);
                zdo.Set(zdoVariantVar, item.m_variant);

                zdo.Set($"{zdoVar}durability", item.m_durability);
                zdo.Set($"{zdoVar}stack", item.m_stack);
                zdo.Set($"{zdoVar}quality", item.m_quality);
                zdo.Set($"{zdoVar}variant", item.m_variant);
                zdo.Set($"{zdoVar}crafterID", item.m_crafterID);
                zdo.Set($"{zdoVar}crafterName", item.m_crafterName);
            }
 private static void CreateNewZDOPostfix(ref ZDO __result)
 {
     if (BetterContinents.Settings.EnabledForThisWorld && ZoneSystemPatch.TagLocationZDOs > 0)
     {
         __result.Set("bc_loc", 1);
     }
     if (BetterContinents.Settings.EnabledForThisWorld && ZoneSystemPatch.TagVegetationZDOs > 0)
     {
         __result.Set("bc_veg", 1);
     }
     if (BetterContinents.Settings.EnabledForThisWorld && CreatureSpawnerPatch.TagSpawnZDOs > 0)
     {
         __result.Set("bc_spawn", 1);
     }
 }
Example #4
0
        public void PlanPieceRemovedFromBlueprint(PlanPiece planPiece)
        {
            ZDOID blueprintID = planPiece.GetBlueprintID();

            if (blueprintID == ZDOID.None)
            {
                return;
            }

            ZDO blueprintZDO = ZDOMan.instance.GetZDO(blueprintID);

            if (blueprintZDO == null)
            {
                return;
            }
            ZDOIDSet planPieces = GetPlanPieces(blueprintZDO);

            planPieces?.Remove(planPiece.GetPlanPieceID());
            if (planPieces == null || planPieces.Count() == 0)
            {
                GameObject blueprintObject = ZNetScene.instance.FindInstance(blueprintID);
                if (blueprintObject)
                {
                    ZNetScene.instance.Destroy(blueprintObject);
                }
            }
            else
            {
                blueprintZDO.Set(PlanPiece.zdoBlueprintPiece, planPieces.ToZPackage().GetArray());
            }
        }
Example #5
0
    // Token: 0x0600025F RID: 607 RVA: 0x0001346C File Offset: 0x0001166C
    private void SaveLootList(CharacterDrop characterDrop)
    {
        List <KeyValuePair <GameObject, int> > list = characterDrop.GenerateDropList();

        if (list.Count > 0)
        {
            ZDO zdo = this.m_nview.GetZDO();
            zdo.Set("drops", list.Count);
            for (int i = 0; i < list.Count; i++)
            {
                KeyValuePair <GameObject, int> keyValuePair = list[i];
                int prefabHash = ZNetScene.instance.GetPrefabHash(keyValuePair.Key);
                zdo.Set("drop_hash" + i, prefabHash);
                zdo.Set("drop_amount" + i, keyValuePair.Value);
            }
        }
    }
Example #6
0
    // Token: 0x0600108C RID: 4236 RVA: 0x000754B8 File Offset: 0x000736B8
    private void Save()
    {
        if (this.m_nview == null)
        {
            return;
        }
        ZDO zdo = this.m_nview.GetZDO();

        zdo.Set("rooms", DungeonGenerator.m_placedRooms.Count);
        for (int i = 0; i < DungeonGenerator.m_placedRooms.Count; i++)
        {
            Room   room = DungeonGenerator.m_placedRooms[i];
            string text = "room" + i.ToString();
            zdo.Set(text, room.GetHash());
            zdo.Set(text + "_pos", room.transform.position);
            zdo.Set(text + "_rot", room.transform.rotation);
        }
    }
Example #7
0
        public static void SaveMagicItem(string guid, MagicItem magicItem)
        {
            if (_zdo == null)
            {
                Debug.LogError($"Tried to save magic item ({guid}) but _zdo was null!");
                return;
            }

            _zdo.Set(guid, JsonMapper.ToJson(magicItem));
        }
Example #8
0
        public void Initialize(BountyInfo bounty, string monsterID, bool isAdd)
        {
            _zdo.Set(BountyIDKey, bounty.ID);

            var pkg = new ZPackage();

            bounty.ToPackage(pkg);
            pkg.SetPos(0);
            _zdo.Set(BountyDataKey, pkg.GetBase64());
            _zdo.Set(MonsterIDKey, monsterID);
            _zdo.Set(IsAddKey, isAdd);
            _zdo.Set(BountyTargetNameKey, GetTargetName(_character.m_name, isAdd, bounty.TargetName));

            _character.SetLevel(GetTargetLevel(bounty, monsterID, isAdd));
            _character.SetMaxHealth(GetModifiedMaxHealth(_character, bounty, isAdd));
            _character.m_baseAI.SetPatrolPoint();

            Reinitialize();
        }
    public void Modify(GameObject entity, ZDO entityZdo)
    {
        if (string.IsNullOrWhiteSpace(TemplateId))
        {
            return;
        }

        Log.LogTrace($"Setting template id {TemplateId}");
        entityZdo?.Set(ZdoFeatureHash, TemplateId);
    }
Example #10
0
            static bool Prefix(ref CookingStation __instance, ref ZNetView ___m_nview, Humanoid user, bool hold)
            {
                if (hold)
                {
                    return(false);
                }

                Traverse t_cookingStation = Traverse.Create(__instance);
                ZDO      zdo = ___m_nview.GetZDO();

                for (int slot = 0; slot < __instance.m_slots.Length; ++slot)
                {
                    string itemName   = zdo.GetString(nameof(slot) + slot);
                    bool   isItemDone = t_cookingStation.Method("IsItemDone", itemName).GetValue <bool>();

                    if (itemName != "" && itemName != __instance.m_overCookedItem.name && isItemDone)
                    {
                        JustAnotherCookingSkill.raiseCookingSkill(user, JustAnotherCookingSkill.cookingStaticExperienceGain.Value * 0.5f);

                        string qualityPrefix = JustAnotherCookingSkill.getQualityBasedOnSkill(user);

                        // check if such object exist
                        string qualifyMealName = qualityPrefix + itemName;
                        if (Prefab.Cache.GetPrefab <ItemDrop>(qualifyMealName) == null)
                        {
                            Log.LogError($"No object registered for qualify meal: {qualifyMealName}");
                            return(true);
                        }

                        // instead of processing normal food, we spawn qualified variant
                        MethodInfo method = __instance.GetType().GetMethod("SpawnItem");
                        if (method == null)
                        {
                            Log.LogError("Method SpawnItem does not exist on type CookingStation");
                            return(true);
                        }

                        method.Invoke(__instance, new object[] { qualifyMealName });

                        zdo.Set("slot" + slot, "");

                        ___m_nview.InvokeRPC(ZNetView.Everybody, "SetSlotVisual", new object[]
                        {
                            slot,
                            ""
                        });

                        // Unfortunately we replace this hook totally and extra modifications will conflict on those. I gonna find better way
                        return(false);
                    }
                }

                return(true);
            }
Example #11
0
    public void Modify(GameObject entity, ZDO entityZdo)
    {
        if (entityZdo is null)
        {
            return;
        }

        if (DespawnOnAlert)
        {
            entityZdo.Set(ZdoFeature, DespawnOnAlert);
        }
    }
Example #12
0
    public void Modify(GameObject entity, ZDO entityZdo)
    {
        if (entityZdo is null)
        {
            return;
        }

        entityZdo.Set(ZdoFeature, true);

        if (ConditionAllowDuringDay is not null)
        {
            entityZdo.Set(ZdoConditionDayHash, ConditionAllowDuringDay.Value);
        }
        if (ConditionAllowDuringNight is not null)
        {
            entityZdo.Set(ZdoConditionNightHash, ConditionAllowDuringNight.Value);
        }
        if (ConditionAllowDuringEnvironments is not null)
        {
            entityZdo.Set(ZdoConditionEnvironmentHash, ConditionAllowDuringEnvironments);
        }
    }
Example #13
0
    public void Modify(GameObject entity, ZDO entityZdo)
    {
        if (entityZdo is null)
        {
            return;
        }

        if (Relentless)
        {
            Log.LogDebug("Setting relentless");
            entityZdo.Set(ZdoFeatureHash, Relentless);
        }
    }
Example #14
0
        public static void Postfix(Fireplace __instance, ZNetView ___m_nview)
        {
            __instance.m_secPerFuel = 0.000001f;

            if (___m_nview != null)
            {
                ZDO zdo = ___m_nview.GetZDO();
                if (zdo != null)
                {
                    zdo.Set("fuel", __instance.m_maxFuel + 1);
                }
            }
        }
Example #15
0
        public static void Postfix(Character __instance, HitData hit, Tameable __state)
        {
            if (Configuration.Current.Tameable.IsEnabled)
            {
                Character character = __instance;
                ZDO       zdo       = character.m_nview.GetZDO();
                Tameable  tameable  = __state;

                if (!character.IsTamed() || zdo == null || tameable == null)
                {
                    return;
                }

                if (ShouldSetStunned(character, tameable, hit))
                {
                    character.SetHealth(character.GetMaxHealth());
                    character.m_animator.SetBool("sleeping", true);
                    zdo.Set("sleeping", true);
                    zdo.Set("isRecoveringFromStun", true);
                }
            }
        }
Example #16
0
        public static void Prefix(MonsterAI __instance, ref float dt)
        {
            if (Configuration.Current.Tameable.IsEnabled)
            {
                MonsterAI monsterAI = __instance;
                ZDO       zdo       = monsterAI.m_nview.GetZDO();

                if ((TameableMortalityTypes)Configuration.Current.Tameable.mortality != TameableMortalityTypes.Essential || zdo == null || !zdo.GetBool("isRecoveringFromStun"))
                {
                    return;
                }

                if (monsterAI.m_character.m_moveDir != Vector3.zero)
                {
                    monsterAI.StopMoving();
                }

                if (monsterAI.m_sleepTimer != 0f)
                {
                    monsterAI.m_sleepTimer = 0f;
                }

                float timeSinceStun = zdo.GetFloat("timeSinceStun") + dt;
                zdo.Set("timeSinceStun", timeSinceStun);

                if (timeSinceStun >= Configuration.Current.Tameable.stunRecoveryTime)
                {
                    zdo.Set("timeSinceStun", 0f);
                    monsterAI.m_sleepTimer = 0.5f;
                    monsterAI.m_character.m_animator.SetBool("sleeping", false);
                    zdo.Set("sleeping", false);
                    zdo.Set("isRecoveringFromStun", false);
                }

                dt = 0f;
            }
        }
Example #17
0
 // Token: 0x060006DB RID: 1755 RVA: 0x00038A0C File Offset: 0x00036C0C
 public static void SaveToZDO(ItemDrop.ItemData itemData, ZDO zdo)
 {
     zdo.Set("durability", itemData.m_durability);
     zdo.Set("stack", itemData.m_stack);
     zdo.Set("quality", itemData.m_quality);
     zdo.Set("variant", itemData.m_variant);
     zdo.Set("crafterID", itemData.m_crafterID);
     zdo.Set("crafterName", itemData.m_crafterName);
 }
        private static void StoreConfigReferences(ZDO zdo, CharacterDrop drop, List <KeyValuePair <GameObject, int> > drops)
        {
            try
            {
#if DEBUG
                Log.LogDebug($"Packing config references for zdo {zdo.m_uid}");
#endif

                var cache = TempDropListCache.GetDrops(drops);
                cache ??= TempDropListCache.GetDrops(drop); // If we somehow failed to keep a consistent list reference (probably mod conflict). Attempt with the original CharacterDrop instead.

                if (cache is null)
                {
#if DEBUG
                    Log.LogDebug($"Found no drops for zdo {zdo.m_uid}");
#endif
                    return;
                }

                List <DropConfig> package = cache.ConfigByIndex
                                            .Select(x =>
                                                    new DropConfig
                {
                    Index     = x.Key,
                    ConfigKey = x.Value.Config.SectionKey,
                    IsList    = x.Value.Config.IsFromNamedList,
                })
                                            .ToList();

                using (MemoryStream memStream = new MemoryStream())
                {
                    BinaryFormatter binaryFormatter = new BinaryFormatter();
                    binaryFormatter.Serialize(memStream, package);

                    byte[] serialized = memStream.ToArray();

#if DEBUG
                    Log.LogDebug($"Serialized and set drops for zdo {zdo.m_uid}");
#endif

                    zdo.Set(ZDOKey, serialized);
                }
            }
            catch (Exception e)
            {
                Log.LogError("Error while attempting to store configurations for items to be dropped on ragdoll 'puff'.", e);
            }
        }
Example #19
0
 // Token: 0x06000AC7 RID: 2759 RVA: 0x0004DA3C File Offset: 0x0004BC3C
 private IEnumerator ConnectPortals()
 {
     for (;;)
     {
         this.m_tempPortalList.Clear();
         int  index = 0;
         bool done  = false;
         do
         {
             done = ZDOMan.instance.GetAllZDOsWithPrefabIterative(this.m_portalPrefab.name, this.m_tempPortalList, ref index);
             yield return(null);
         }while (!done);
         foreach (ZDO zdo in this.m_tempPortalList)
         {
             ZDOID  zdoid   = zdo.GetZDOID("target");
             string @string = zdo.GetString("tag", "");
             if (!zdoid.IsNone())
             {
                 ZDO zdo2 = ZDOMan.instance.GetZDO(zdoid);
                 if (zdo2 == null || zdo2.GetString("tag", "") != @string)
                 {
                     zdo.SetOwner(ZDOMan.instance.GetMyID());
                     zdo.Set("target", ZDOID.None);
                     ZDOMan.instance.ForceSendZDO(zdo.m_uid);
                 }
             }
         }
         foreach (ZDO zdo3 in this.m_tempPortalList)
         {
             string string2 = zdo3.GetString("tag", "");
             if (zdo3.GetZDOID("target").IsNone())
             {
                 ZDO zdo4 = this.FindRandomUnconnectedPortal(this.m_tempPortalList, zdo3, string2);
                 if (zdo4 != null)
                 {
                     zdo3.SetOwner(ZDOMan.instance.GetMyID());
                     zdo4.SetOwner(ZDOMan.instance.GetMyID());
                     zdo3.Set("target", zdo4.m_uid);
                     zdo4.Set("target", zdo3.m_uid);
                     ZDOMan.instance.ForceSendZDO(zdo3.m_uid);
                     ZDOMan.instance.ForceSendZDO(zdo4.m_uid);
                 }
             }
         }
         yield return(new WaitForSeconds(5f));
     }
     yield break;
 }
Example #20
0
    public void Modify(GameObject entity, ZDO entityZdo)
    {
        var character = ComponentCache.Get <Character>(entity);

        if (character is null)
        {
            return;
        }

        var tameable = ComponentCache.Get <Tameable>(entity);

        if (tameable is not null && tameable)
        {
#if DEBUG
            Log.LogDebug($"Setting tamed commandable");
#endif
            tameable.m_commandable = Commandable;
            entityZdo?.Set(ZdoFeatureHash, Commandable);
        }
    }
Example #21
0
    // Token: 0x060009C5 RID: 2501 RVA: 0x00046F2C File Offset: 0x0004512C
    private void SyncParameters()
    {
        ZDO zdo = this.m_nview.GetZDO();

        if (!this.m_nview.IsOwner())
        {
            for (int i = 0; i < this.m_boolHashes.Length; i++)
            {
                int  num   = this.m_boolHashes[i];
                bool @bool = zdo.GetBool(438569 + num, this.m_boolDefaults[i]);
                this.m_animator.SetBool(num, @bool);
            }
            for (int j = 0; j < this.m_floatHashes.Length; j++)
            {
                int   num2   = this.m_floatHashes[j];
                float @float = zdo.GetFloat(438569 + num2, this.m_floatDefaults[j]);
                if (this.m_smoothCharacterSpeeds && (num2 == ZSyncAnimation.m_forwardSpeedID || num2 == ZSyncAnimation.m_sidewaySpeedID))
                {
                    this.m_animator.SetFloat(num2, @float, 0.2f, Time.fixedDeltaTime);
                }
                else
                {
                    this.m_animator.SetFloat(num2, @float);
                }
            }
            for (int k = 0; k < this.m_intHashes.Length; k++)
            {
                int num3 = this.m_intHashes[k];
                int @int = zdo.GetInt(438569 + num3, this.m_intDefaults[k]);
                this.m_animator.SetInteger(num3, @int);
            }
            float float2 = zdo.GetFloat(ZSyncAnimation.m_animSpeedID, 1f);
            this.m_animator.speed = float2;
            return;
        }
        zdo.Set(ZSyncAnimation.m_animSpeedID, this.m_animator.speed);
    }
Example #22
0
    // Token: 0x060009D4 RID: 2516 RVA: 0x000473A4 File Offset: 0x000455A4
    private void OwnerSync()
    {
        ZDO zdo = this.m_nview.GetZDO();

        if (!zdo.IsOwner())
        {
            return;
        }
        if (base.transform.position.y < -5000f)
        {
            if (this.m_body)
            {
                this.m_body.velocity = Vector3.zero;
            }
            ZLog.Log("Object fell out of world:" + base.gameObject.name);
            float   groundHeight = ZoneSystem.instance.GetGroundHeight(base.transform.position);
            Vector3 position     = base.transform.position;
            position.y = groundHeight + 1f;
            base.transform.position = position;
            return;
        }
        if (this.m_syncPosition)
        {
            zdo.SetPosition(this.GetPosition());
            zdo.Set(ZSyncTransform.m_velHash, this.GetVelocity());
            if (this.m_characterParentSync)
            {
                ZDOID   id;
                Vector3 value;
                Vector3 value2;
                if (this.m_character.GetRelativePosition(out id, out value, out value2))
                {
                    zdo.Set(ZSyncTransform.m_parentIDHash, id);
                    zdo.Set(ZSyncTransform.m_relPos, value);
                    zdo.Set(ZSyncTransform.m_velHash, value2);
                }
                else
                {
                    zdo.Set(ZSyncTransform.m_parentIDHash, ZDOID.None);
                }
            }
        }
        if (this.m_syncRotation && base.transform.hasChanged)
        {
            Quaternion rotation = this.m_body ? this.m_body.rotation : base.transform.rotation;
            zdo.SetRotation(rotation);
        }
        if (this.m_syncScale && base.transform.hasChanged)
        {
            zdo.Set(ZSyncTransform.m_scaleHash, base.transform.localScale);
        }
        if (this.m_body)
        {
            if (this.m_syncBodyVelocity)
            {
                this.m_nview.GetZDO().Set(ZSyncTransform.m_bodyVel, this.m_body.velocity);
                this.m_nview.GetZDO().Set(ZSyncTransform.m_bodyAVel, this.m_body.angularVelocity);
            }
            this.m_body.useGravity = this.m_useGravity;
        }
        base.transform.hasChanged = false;
    }
Example #23
0
 /// <summary>
 /// Sets "faction" in zdo.
 /// </summary>
 /// <remarks>Spawn That setting.</remarks>
 public static void SetFaction(this ZDO zdo, Character.Faction faction)
 {
     zdo.Set(FactionHash, (int)faction);
 }
Example #24
0
        private static bool PlaceBlueprint(Player player, Piece piece)
        {
            Blueprint bp        = Instance.m_blueprints[piece.m_name];
            var       transform = player.m_placementGhost.transform;
            var       position  = player.m_placementGhost.transform.position;
            var       rotation  = player.m_placementGhost.transform.rotation;

            bool placeDirect = ZInput.GetButton("Crouch");

            if (placeDirect && !allowDirectBuildConfig.Value)
            {
                MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, "$msg_direct_build_disabled");
                return(false);
            }

            if (ZInput.GetButton("AltPlace"))
            {
                Vector2 extent = bp.GetExtent();
                FlattenTerrain.FlattenForBlueprint(transform, extent.x, extent.y, bp.m_pieceEntries);
            }

            uint cntEffects = 0u;
            uint maxEffects = 10u;

            GameObject blueprintPrefab = PrefabManager.Instance.GetPrefab(Blueprint.BlueprintPrefabName);
            GameObject blueprintObject = Object.Instantiate(blueprintPrefab, position, rotation);

            ZDO blueprintZDO = blueprintObject.GetComponent <ZNetView>().GetZDO();

            blueprintZDO.Set(ZDOBlueprintName, bp.m_name);
            ZDOIDSet createdPlans = new ZDOIDSet();

            for (int i = 0; i < bp.m_pieceEntries.Length; i++)
            {
                PieceEntry entry = bp.m_pieceEntries[i];
                // Final position
                Vector3 entryPosition = position + transform.forward * entry.posZ + transform.right * entry.posX + new Vector3(0, entry.posY, 0);

                // Final rotation
                Quaternion entryQuat = new Quaternion(entry.rotX, entry.rotY, entry.rotZ, entry.rotW);
                entryQuat.eulerAngles += rotation.eulerAngles;

                // Get the prefab of the piece or the plan piece
                string prefabName = entry.name;
                if (!placeDirect)
                {
                    prefabName += PlanPiecePrefab.PlannedSuffix;
                }

                GameObject prefab = PrefabManager.Instance.GetPrefab(prefabName);
                if (!prefab)
                {
                    Jotunn.Logger.LogWarning(entry.name + " not found, you are probably missing a dependency for blueprint " + bp.m_name + ", not placing @ " + entryPosition);
                    continue;
                }

                // Instantiate a new object with the new prefab
                GameObject gameObject = Object.Instantiate(prefab, entryPosition, entryQuat);

                ZNetView zNetView = gameObject.GetComponent <ZNetView>();
                if (!zNetView)
                {
                    Jotunn.Logger.LogWarning("No ZNetView for " + gameObject + "!!??");
                }
                else if (gameObject.TryGetComponent(out PlanPiece planPiece))
                {
                    planPiece.PartOfBlueprint(blueprintZDO.m_uid, entry);
                    createdPlans.Add(planPiece.GetPlanPieceID());
                }

                // Register special effects
                CraftingStation craftingStation = gameObject.GetComponentInChildren <CraftingStation>();
                if (craftingStation)
                {
                    player.AddKnownStation(craftingStation);
                }
                Piece newpiece = gameObject.GetComponent <Piece>();
                if (newpiece)
                {
                    newpiece.SetCreator(player.GetPlayerID());
                }
                PrivateArea privateArea = gameObject.GetComponent <PrivateArea>();
                if (privateArea)
                {
                    privateArea.Setup(Game.instance.GetPlayerProfile().GetName());
                }
                WearNTear wearntear = gameObject.GetComponent <WearNTear>();
                if (wearntear)
                {
                    wearntear.OnPlaced();
                }
                TextReceiver textReceiver = gameObject.GetComponent <TextReceiver>();
                if (textReceiver != null)
                {
                    textReceiver.SetText(entry.additionalInfo);
                }

                // Limited build effects
                if (cntEffects < maxEffects)
                {
                    newpiece.m_placeEffect.Create(gameObject.transform.position, rotation, gameObject.transform, 1f);
                    player.AddNoise(50f);
                    cntEffects++;
                }

                // Count up player builds
                Game.instance.GetPlayerProfile().m_playerStats.m_builds++;
            }

            blueprintZDO.Set(PlanPiece.zdoBlueprintPiece, createdPlans.ToZPackage().GetArray());

            // Dont set the blueprint piece and clutter the world with it
            return(false);
        }