public void ItemUse(NwWalkerGameObject go, WalkerPlayer player, bool sync) { MMW.Invoke(() => { try { if (!Players.Exists(p => (string)p.Properties["userID"] == player.UserID)) { return; } var wo = Resources.Objects[go.ObjectHash]; if (!wo.Loaded) { wo.Load(); } var g = GameObjectFactory.CreateItem(go, wo, player, "item", wo.Bones != null ? "Deferred Physical Skin" : "Deferred Physical"); g.Properties["user"] = player; g.Properties["userID"] = player.UserID; g.Properties["sessionID"] = player.SessionID; g.Hash = go.Hash; g.Transform.Parent = Players.Find(p => (string)p.Properties["userID"] == player.UserID).Transform; g.Transform.UpdatePhysicalTransform(); MMW.RegistGameObject(g); if (sync) { SyncWorldObjects.Add(g); } else { WorldObjects.Add(g); } } catch { MMW.BroadcastMessage("log", $"[ERROR] failed to use item \"{go.Name}\""); } }); }
public void PutGameObject(NwWalkerGameObject go, bool sync) { MMW.Invoke(() => { try { var wo = Resources.Objects[go.ObjectHash]; if (!wo.Loaded) { wo.Load(); } var g = GameObjectFactory.CreateGameObject(go, wo, wo.Name, wo.Bones != null ? "Deferred Physical Skin" : "Deferred Physical"); g.Hash = go.Hash; g.Transform.Position = go.Position.FromVec3f(); g.Transform.Rotate = go.Rotation.FromVec3f(); if (go.Scale != null) { g.Transform.Scale = go.Scale.FromVec3f(); } g.Transform.UpdatePhysicalTransform(); MMW.RegistGameObject(g); if (sync) { SyncWorldObjects.Add(g); } else { WorldObjects.Add(g); } } catch { MMW.BroadcastMessage("log", $"[ERROR] object \"{go.Name}\" entry failed"); } }); }