// 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); } }
// Token: 0x0600108D RID: 4237 RVA: 0x00075570 File Offset: 0x00073770 private void Load() { if (this.m_nview == null) { return; } DateTime now = DateTime.Now; ZLog.Log("Loading dungeon"); ZDO zdo = this.m_nview.GetZDO(); int @int = zdo.GetInt("rooms", 0); for (int i = 0; i < @int; i++) { string text = "room" + i.ToString(); int int2 = zdo.GetInt(text, 0); Vector3 vec = zdo.GetVec3(text + "_pos", Vector3.zero); Quaternion quaternion = zdo.GetQuaternion(text + "_rot", Quaternion.identity); DungeonDB.RoomData room = DungeonDB.instance.GetRoom(int2); if (room == null) { ZLog.LogWarning("Missing room:" + int2); } else { this.PlaceRoom(room, vec, quaternion, null, ZoneSystem.SpawnMode.Client); } } ZLog.Log("Dungeon loaded " + @int); ZLog.Log("Dungeon load time " + (DateTime.Now - now).TotalMilliseconds + " ms"); }
public void Modify(GameObject entity, ZDO entityZdo) { if (entity is null) { return; } var character = ComponentCache.Get <Character>(entity); if (character is null) { return; } if (Faction is null) { return; } #if DEBUG Log.LogDebug($"Setting faction {Faction}"); #endif character.m_faction = Faction.Value; entityZdo?.SetFaction(Faction.Value); }
// Token: 0x060007F5 RID: 2037 RVA: 0x0003EA37 File Offset: 0x0003CC37 public static ZDO Create(ZDOMan man) { ZDO zdo = ZDOPool.Get(); zdo.Initialize(man); return(zdo); }
// Token: 0x0600087C RID: 2172 RVA: 0x00041424 File Offset: 0x0003F624 private GameObject CreateObject(ZDO zdo) { int prefab = zdo.GetPrefab(); if (prefab == 0) { return(null); } GameObject prefab2 = this.GetPrefab(prefab); if (prefab2 == null) { return(null); } Vector3 position = zdo.GetPosition(); Quaternion rotation = zdo.GetRotation(); ZNetView.m_useInitZDO = true; ZNetView.m_initZDO = zdo; GameObject result = UnityEngine.Object.Instantiate <GameObject>(prefab2, position, rotation); if (ZNetView.m_initZDO != null) { ZLog.LogWarning(string.Concat(new object[] { "ZDO ", zdo.m_uid, " not used when creating object ", prefab2.name })); ZNetView.m_initZDO = null; } ZNetView.m_useInitZDO = false; return(result); }
// Token: 0x060007F4 RID: 2036 RVA: 0x0003EA27 File Offset: 0x0003CC27 public static ZDO Create(ZDOMan man, ZDOID id, Vector3 position) { ZDO zdo = ZDOPool.Get(); zdo.Initialize(man, id, position); return(zdo); }
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()); } }
private void syncPositionAndRotation(ZDO zdo, float dt) { if (zdo == null) { return; } var vr_data = zdo.GetByteArray("vr_data"); if (vr_data == null) { return; } ZPackage pkg = new ZPackage(vr_data); var currentDataRevision = zdo.m_dataRevision; if (currentDataRevision != lastDataRevision) { // New data revision since last sync so we reset our deltaT counter deltaTimeCounter = 0f; // Save the current data revision so we can detect the next new data package lastDataRevision = currentDataRevision; } deltaTimeCounter += dt; deltaTimeCounter = Mathf.Min(deltaTimeCounter, 2f); extractAndUpdate(pkg, ref camera, ref clientTempRelPosCamera, hasTempRelPos); extractAndUpdate(pkg, ref leftHand, ref clientTempRelPosLeft, hasTempRelPos); extractAndUpdate(pkg, ref rightHand, ref clientTempRelPosRight, hasTempRelPos); maybeAddVrik(); hasTempRelPos = true; readFingers(pkg); maybePullBow(pkg.ReadBool()); }
// Token: 0x060007E1 RID: 2017 RVA: 0x0003E3DC File Offset: 0x0003C5DC private void FindDistantObjects(Vector2i sector, List <ZDO> objects) { int num = this.SectorToIndex(sector); List <ZDO> list2; if (num >= 0) { List <ZDO> list = this.m_objectsBySector[num]; if (list != null) { for (int i = 0; i < list.Count; i++) { ZDO zdo = list[i]; if (zdo.m_distant) { objects.Add(zdo); } } return; } } else if (this.m_objectsByOutsideSector.TryGetValue(sector, out list2)) { for (int j = 0; j < list2.Count; j++) { ZDO zdo2 = list2[j]; if (zdo2.m_distant) { objects.Add(zdo2); } } } }
// Token: 0x06000260 RID: 608 RVA: 0x00013508 File Offset: 0x00011708 private void SpawnLoot(Vector3 center) { ZDO zdo = this.m_nview.GetZDO(); int @int = zdo.GetInt("drops", 0); if (@int <= 0) { return; } List <KeyValuePair <GameObject, int> > list = new List <KeyValuePair <GameObject, int> >(); for (int i = 0; i < @int; i++) { int int2 = zdo.GetInt("drop_hash" + i, 0); int int3 = zdo.GetInt("drop_amount" + i, 0); GameObject prefab = ZNetScene.instance.GetPrefab(int2); if (prefab == null) { ZLog.LogWarning("Ragdoll: Missing prefab:" + int2 + " when dropping loot"); } else { list.Add(new KeyValuePair <GameObject, int>(prefab, int3)); } } CharacterDrop.DropItems(list, center + Vector3.up * 0.75f, 0.5f); }
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() }); } } } }
internal void PartOfBlueprint(ZDOID blueprintID, PieceEntry entry) { ZDO pieceZDO = m_nView.GetZDO(); pieceZDO.Set(zdoBlueprintID, blueprintID); pieceZDO.Set(zdoAdditionalInfo, entry.additionalInfo); }
private static void InitBackpack() { Dbgl("Initializing backpack."); backpack.transform.localPosition = Vector3.zero; backpack.name = backpackObjectName; if (backpack.GetComponent <WearNTear>()) { Destroy(backpack.GetComponent <WearNTear>()); } if (backpack.GetComponent <Piece>()) { Destroy(backpack.GetComponent <Piece>()); } if (backpack.transform.Find("New")) { Destroy(backpack.transform.Find("New").gameObject); } backpack.GetComponent <Container>().m_name = backpackName.Value; Traverse.Create(Traverse.Create(backpack.GetComponent <Container>()).Field("m_inventory").GetValue <Inventory>()).Field("m_name").SetValue(backpackName.Value); Traverse.Create(Traverse.Create(backpack.GetComponent <Container>()).Field("m_inventory").GetValue <Inventory>()).Field("m_width").SetValue((int)Math.Min(8, backpackSize.Value.x)); Traverse.Create(Traverse.Create(backpack.GetComponent <Container>()).Field("m_inventory").GetValue <Inventory>()).Field("m_height").SetValue((int)backpackSize.Value.y); backpackZDO = backpack.GetComponent <ZNetView>().GetZDO(); ResetBackpackSector(); }
// Token: 0x06000F7A RID: 3962 RVA: 0x0006DBD0 File Offset: 0x0006BDD0 public void Teleport(Player player) { if (!this.TargetFound()) { return; } if (!player.IsTeleportable()) { player.Message(MessageHud.MessageType.Center, "$msg_noteleport", 0, null); return; } ZLog.Log("Teleporting " + player.GetPlayerName()); ZDOID zdoid = this.m_nview.GetZDO().GetZDOID("target"); if (zdoid == ZDOID.None) { return; } ZDO zdo = ZDOMan.instance.GetZDO(zdoid); Vector3 position = zdo.GetPosition(); Quaternion rotation = zdo.GetRotation(); Vector3 a = rotation * Vector3.forward; Vector3 pos = position + a * this.m_exitDistance + Vector3.up; player.TeleportTo(pos, rotation, true); }
private void Start() { var prefab = this.gameObject; ZNetView znv = prefab.GetComponent <ZNetView>(); ZDO zdo = prefab.GetComponent <ZNetView>().GetZDO(); DestroyImmediate(prefab.GetComponent <ZNetView>()); DestroyImmediate(prefab.GetComponent <ZSyncAnimation>()); DestroyImmediate(prefab.GetComponent <ZSyncTransform>()); DestroyImmediate(prefab.GetComponent <MonsterAI>()); DestroyImmediate(prefab.GetComponent <VisEquipment>()); DestroyImmediate(prefab.GetComponent <CharacterDrop>()); DestroyImmediate(prefab.GetComponent <Humanoid>()); DestroyImmediate(prefab.GetComponent <FootStep>()); DestroyImmediate(prefab.GetComponent <Rigidbody>()); foreach (var comp in gameObject.GetComponents <Component>()) { if (!(comp is Transform) && !(comp is OdinShaman) && !(comp is CapsuleCollider)) { DestroyImmediate(comp); } } var a = Traverse.Create(ZNetScene.instance).Field <Dictionary <ZDO, ZNetView> >("m_instances").Value; a.Remove(zdo); ZDOMan.instance.DestroyZDO(zdo); prefab.gameObject.transform.Rotate(0, 30f, 0); }
/// <summary> /// Updates the internal list of known Portals. Any Portals destroyed are placed in the removed portals list /// </summary> /// <param name="zdos"></param> public void UpdatePortals(List <ZDO> zdos) { List <Portal> removed = new List <Portal>(); foreach (Portal p in _portals) { ZDO obj = zdos.FirstOrDefault(z => z.m_uid == p.Id); if (obj == null) { removed.Add(p); } } foreach (Portal p in removed) { _portals.Remove(p); _removedPortals.Add(p); } foreach (ZDO z in zdos) { Portal existing = GetPortalByZDOID(z.m_uid); if (existing == null) { _portals.Add(new Portal(z)); } } UpdateConnectedPortals(); }
// Token: 0x060007BF RID: 1983 RVA: 0x0003D014 File Offset: 0x0003B214 public void ZDOSectorInvalidated(ZDO zdo) { foreach (ZDOMan.ZDOPeer zdopeer in this.m_peers) { zdopeer.ZDOSectorInvalidated(zdo); } }
public void Modify(GameObject entity, ZDO entityZdo) { if (MaxLevel <= 1) { return; } if (MinDistanceForLevelups > 0 && entityZdo.m_position.magnitude < MinDistanceForLevelups) { return; } int minLevel = Math.Max(1, MinLevel); int level = minLevel; for (; level < MaxLevel; ++level) { if (UnityEngine.Random.Range(0f, 100f) > LevelupChance) { break; } } if (minLevel > 1) { Character character = ComponentCache.Get <Character>(entity); if (character != null && character) { character.SetLevel(minLevel); } } }
// Token: 0x060007D9 RID: 2009 RVA: 0x0003E01C File Offset: 0x0003C21C private void ServerSortSendZDOS(List <ZDO> objects, Vector3 refPos, ZDOMan.ZDOPeer peer) { float time = Time.time; for (int i = 0; i < objects.Count; i++) { ZDO zdo = objects[i]; Vector3 position = zdo.GetPosition(); zdo.m_tempSortValue = Vector3.Distance(position, refPos); float num = 100f; ZDOMan.ZDOPeer.PeerZDOInfo peerZDOInfo; if (peer.m_zdos.TryGetValue(zdo.m_uid, out peerZDOInfo)) { num = Mathf.Clamp(time - peerZDOInfo.m_syncTime, 0f, 100f); zdo.m_tempHaveRevision = true; } else { zdo.m_tempHaveRevision = false; } zdo.m_tempSortValue -= num * 1.5f; } ZDOMan.compareReceiver = peer.m_peer.m_uid; objects.Sort(new Comparison <ZDO>(ZDOMan.ServerSendCompare)); }
// Token: 0x060007BE RID: 1982 RVA: 0x0003CF98 File Offset: 0x0003B198 public void AddToSector(ZDO zdo, Vector2i sector) { int num = this.SectorToIndex(sector); if (num >= 0) { if (this.m_objectsBySector[num] != null) { this.m_objectsBySector[num].Add(zdo); return; } List <ZDO> list = new List <ZDO>(); list.Add(zdo); this.m_objectsBySector[num] = list; return; } else { List <ZDO> list2; if (this.m_objectsByOutsideSector.TryGetValue(sector, out list2)) { list2.Add(zdo); return; } list2 = new List <ZDO>(); list2.Add(zdo); this.m_objectsByOutsideSector.Add(sector, list2); return; } }
public void Modify(GameObject entity, ZDO entityZdo) { var character = ComponentCache.Get <Character>(entity); if (character is null) { return; } string aiConfig = "{}"; if (!string.IsNullOrWhiteSpace(Config)) { aiConfig = Config; } try { MobManager.RegisterMob(character, Guid.NewGuid().ToString(), AiName, aiConfig); Log.LogTrace($"Set AI '{AiName}' for spawn '{entity.name}'."); } catch (Exception e) { Log.LogError($"Failure while attempting to set AI '{AiName}' for spawn '{entity.name}'", e); } }
// Token: 0x060007D0 RID: 2000 RVA: 0x0003D640 File Offset: 0x0003B840 private void HandleDestroyedZDO(ZDOID uid) { if (uid.userID == this.m_myid && uid.id >= this.m_nextUid) { this.m_nextUid = uid.id + 1U; } ZDO zdo = this.GetZDO(uid); if (zdo == null) { return; } if (this.m_onZDODestroyed != null) { this.m_onZDODestroyed(zdo); } this.RemoveFromSector(zdo, zdo.GetSector()); this.m_objectsByID.Remove(zdo.m_uid); ZDOPool.Release(zdo); foreach (ZDOMan.ZDOPeer zdopeer in this.m_peers) { zdopeer.m_zdos.Remove(uid); } if (ZNet.instance.IsServer()) { long ticks = ZNet.instance.GetTime().Ticks; this.m_deadZDOs[uid] = ticks; } }
// Token: 0x060007D6 RID: 2006 RVA: 0x0003DD08 File Offset: 0x0003BF08 private void CreateSyncList(ZDOMan.ZDOPeer peer, List <ZDO> toSync) { if (ZNet.instance.IsServer()) { Vector3 refPos = peer.m_peer.GetRefPos(); Vector2i zone = ZoneSystem.instance.GetZone(refPos); this.m_tempToSyncDistant.Clear(); this.FindSectorObjects(zone, ZoneSystem.instance.m_activeArea, ZoneSystem.instance.m_activeDistantArea, toSync, this.m_tempToSyncDistant); this.ServerSortSendZDOS(toSync, refPos, peer); toSync.AddRange(this.m_tempToSyncDistant); this.AddForceSendZdos(peer, toSync); return; } this.m_tempRemoveList.Clear(); foreach (ZDOID zdoid in this.m_clientChangeQueue) { ZDO zdo = this.GetZDO(zdoid); if (zdo != null) { toSync.Add(zdo); } else { this.m_tempRemoveList.Add(zdoid); } } foreach (ZDOID item in this.m_tempRemoveList) { this.m_clientChangeQueue.Remove(item); } this.ClientSortSendZDOS(toSync, peer); this.AddForceSendZdos(peer, toSync); }
// Token: 0x060007CD RID: 1997 RVA: 0x0003D550 File Offset: 0x0003B750 public void DestroyZDO(ZDO zdo) { if (!zdo.IsOwner()) { return; } this.m_destroySendList.Add(zdo.m_uid); }
// Token: 0x0600087A RID: 2170 RVA: 0x000413C0 File Offset: 0x0003F5C0 public void AddInstance(ZDO zdo, ZNetView nview) { this.m_instances[zdo] = nview; if (nview.transform.parent == null) { nview.transform.SetParent(this.m_netSceneRoot.transform); } }
// Token: 0x060006DC RID: 1756 RVA: 0x00038A80 File Offset: 0x00036C80 public static void LoadFromZDO(ItemDrop.ItemData itemData, ZDO zdo) { itemData.m_durability = zdo.GetFloat("durability", itemData.m_durability); itemData.m_stack = zdo.GetInt("stack", itemData.m_stack); itemData.m_quality = zdo.GetInt("quality", itemData.m_quality); itemData.m_variant = zdo.GetInt("variant", itemData.m_variant); itemData.m_crafterID = zdo.GetLong("crafterID", itemData.m_crafterID); itemData.m_crafterName = zdo.GetString("crafterName", itemData.m_crafterName); }
// 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 ZDOIDSet GetPlanPieces(ZDO blueprintZDO) { byte[] data = blueprintZDO.GetByteArray(PlanPiece.zdoBlueprintPiece); if (data == null) { return(null); } return(ZDOIDSet.From(new ZPackage(data))); }
// Token: 0x060007BD RID: 1981 RVA: 0x0003CF50 File Offset: 0x0003B150 public ZDO CreateNewZDO(ZDOID uid, Vector3 position) { ZDO zdo = ZDOPool.Create(this, uid, position); zdo.m_owner = this.m_myid; zdo.m_timeCreated = ZNet.instance.GetTime().Ticks; this.m_objectsByID.Add(uid, zdo); return(zdo); }
// Token: 0x060007D8 RID: 2008 RVA: 0x0003DF20 File Offset: 0x0003C120 private static int ServerSendCompare(ZDO x, ZDO y) { bool flag = x.m_owner != ZDOMan.compareReceiver; bool flag2 = y.m_owner != ZDOMan.compareReceiver; if (flag && flag2) { if (x.m_type == y.m_type) { return(x.m_tempSortValue.CompareTo(y.m_tempSortValue)); } if (x.m_type == ZDO.ObjectType.Prioritized) { return(-1); } if (y.m_type == ZDO.ObjectType.Prioritized) { return(1); } return(x.m_tempSortValue.CompareTo(y.m_tempSortValue)); } else { if (flag != flag2) { if (flag && x.m_type == ZDO.ObjectType.Prioritized) { return(-1); } if (flag2 && y.m_type == ZDO.ObjectType.Prioritized) { return(1); } } if (x.m_type == y.m_type) { return(x.m_tempSortValue.CompareTo(y.m_tempSortValue)); } if (x.m_type == ZDO.ObjectType.Solid) { return(-1); } if (y.m_type == ZDO.ObjectType.Solid) { return(1); } if (x.m_type == ZDO.ObjectType.Prioritized) { return(-1); } if (y.m_type == ZDO.ObjectType.Prioritized) { return(1); } return(x.m_tempSortValue.CompareTo(y.m_tempSortValue)); } }