private void readPidControllerConfiguration(GameObjectTemplate template, ulong physicsObjectId) { if (template.pidControllerConfiguration != null) { attitudeAndAccelerationControlResponsibility.PidControlConfigurationByPhysicsObjectId[physicsObjectId] = template.pidControllerConfiguration; } }
void buildAndAddRenderingMesh(GameObjectTemplate template, PhysicsComponent physicsComponent) { if (template.meshPath == "meta:fromMainShape") // the mesh is derived from the mainshape { MeshWithExplicitFaces renderMesh; if (template.mainMassShapeType == "box") { renderMesh = PlatonicFactory.createBox(template.mainMassDimensions[0], template.mainMassDimensions[1], template.mainMassDimensions[2]); } else { throw new NotImplementedException("meta:fromMainShape mesh path is not implemented for shape " + template.meshPath + "!"); } MeshComponent meshComponent = new MeshComponent(); meshComponent.mesh = renderMesh; TransformedMeshComponent transformedMeshComponentForRendering = new TransformedMeshComponent(); transformedMeshComponentForRendering.meshComponent = meshComponent; softwareRenderer.physicsAndMeshPairs.Add(new PhysicsComponentAndMeshPair(physicsComponent, transformedMeshComponentForRendering)); } else { throw new NotImplementedException(); } }
/// <summary> /// Builds the module for this slime /// </summary> protected virtual void BuildModule() { GameObjectTemplate module = new GameObjectTemplate("module" + mainObject.Name); module.AddComponents(extras.ToArray()); module.AddComponents( new Create <SlimeEat>((eat) => { eat.slimeDefinition = definition; eat.damagePerAttack = 20; eat.EatFX = EffectObjects.fxSlimeEat; eat.EatFavoriteFX = EffectObjects.fxSlimeFavEat; eat.ProduceFX = EffectObjects.fxSlimeProduce; eat.TransformFX = EffectObjects.fxSlimeTrans; eat.minDriveToEat = driveToEat; eat.drivePerEat = drivePerEat; eat.agitationPerEat = agitPerEat; eat.agitationPerFavEat = agitPerFavEat; }), new Create <ReactToToyNearby>((react) => react.slimeDefinition = definition) ); slimeModule = module.ToGameObject(null); definition.SlimeModules = slimeModule.Group(); }
private void buildThrustersAndAddToObject(GameObjectTemplate template, PhysicsComponent @object) { if (template.thrusters == null) { return; } thrusterResponsibility.physicsObjectIdToThrusters[@object.id] = new List <ThrusterResponsibility.ThrusterBinding>(); foreach (serialization.Thruster iThruster in template.thrusters) { SpatialVectorDouble objectLocalPosition = new SpatialVectorDouble(iThruster.locationPosition); SpatialVectorDouble objectLocalDirection = new SpatialVectorDouble(iThruster.direction); double maximalForce = iThruster.maximalForce; AttachedForce attachedForce = new AttachedForce(objectLocalPosition, objectLocalDirection); @object.attachedForces.Add(attachedForce); ThrusterResponsibility.ThrusterBinding thrusterBinding = new ThrusterResponsibility.ThrusterBinding(); thrusterBinding.attachedForce = attachedForce; thrusterBinding.maximalForce = maximalForce; thrusterBinding.tag = iThruster.tag; thrusterResponsibility.physicsObjectIdToThrusters[@object.id].Add(thrusterBinding); } }
public bool SetCapturePointData(uint entry, uint map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3) { Log.outDebug(LogFilter.Outdoorpvp, "Creating capture point {0}", entry); // check info existence GameObjectTemplate goinfo = Global.ObjectMgr.GetGameObjectTemplate(entry); if (goinfo == null || goinfo.type != GameObjectTypes.ControlZone) { Log.outError(LogFilter.Outdoorpvp, "OutdoorPvP: GO {0} is not capture point!", entry); return(false); } m_capturePointSpawnId = Global.ObjectMgr.AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3); if (m_capturePointSpawnId == 0) { return(false); } // get the needed values from goinfo m_maxValue = goinfo.ControlZone.maxTime; m_maxSpeed = m_maxValue / (goinfo.ControlZone.minTime != 0 ? goinfo.ControlZone.minTime : 60); m_neutralValuePct = goinfo.ControlZone.neutralPercent; m_minValue = MathFunctions.CalculatePct(m_maxValue, m_neutralValuePct); return(true); }
SolidCluster buildSolidCluster(GameObjectTemplate template) { SolidCluster solidCluster = new SolidCluster(); if (template.solids == null) { return(solidCluster); } foreach (serialization.Solid iSolid in template.solids) { SpatialVectorDouble solidSize = new SpatialVectorDouble(iSolid.size); double massOfSolidInKilogram = iSolid.fractionMass; IList <CompositionFraction> solidCompositionFractions = new List <CompositionFraction>() { new CompositionFraction(new Isotope(iSolid.fractionIsotopeName), massOfSolidInKilogram) }; Composition solidComposition = new Composition(solidCompositionFractions); physics.solid.Solid solid = physics.solid.Solid.makeBox(solidComposition, solidSize); SpatialVectorDouble solidLocalPosition = new SpatialVectorDouble(iSolid.localPosition); SpatialVectorDouble solidLocalRotation = new SpatialVectorDouble(iSolid.localRotation); solidCluster.solids.Add(new SolidCluster.SolidWithPositionAndRotation(solid, solidLocalPosition, solidLocalRotation)); } return(solidCluster); }
/// <summary> /// Creates the object of the template (To get the prefab version use .ToPrefab() after calling this) /// </summary> public override PlotFrameTemplate Create() { // Create a base post GameObjectTemplate post = new GameObjectTemplate("Post") .AddChild(new GameObjectTemplate("plotBase", new Create <MeshFilter>((filter) => filter.sharedMesh = RanchObjects.plotBase), new Create <MeshRenderer>((render) => render.sharedMaterials = RanchObjects.plotBaseMaterials) )) .AddChild(new GameObjectTemplate("plotPost", new Create <MeshFilter>((filter) => filter.sharedMesh = RanchObjects.plotPost), new Create <MeshRenderer>((render) => render.sharedMaterials = RanchObjects.plotBaseMaterials), new Create <CapsuleCollider>((col) => { col.center = Vector3.up * 2.3f; col.radius = 0.4455906f; col.height = 4.199063f; col.direction = 1; }) )); // Create main object mainObject.AddChild(post.Clone("Post 1").SetTransform(new Vector3(4.8f, 0, -4.8f), Vector3.zero, Vector3.one)); mainObject.AddChild(post.Clone("Post 2").SetTransform(new Vector3(-4.8f, 0, -4.8f), Vector3.up * 90, Vector3.one)); mainObject.AddChild(post.Clone("Post 3").SetTransform(new Vector3(-4.8f, 0, 4.8f), Vector3.up * 180, Vector3.one)); mainObject.AddChild(post.Clone("Post 4").SetTransform(new Vector3(4.8f, 0, 4.8f), Vector3.up * 270, Vector3.one)); return(this); }
public static void HandleGameObjectQueryRequest(ref PacketReader packet, ref WorldSession session) { uint entry = packet.ReadUInt32(); ulong guid = packet.ReadUInt64(); GameObjectTemplate go = Cypher.ObjMgr.GetGameObjectTemplate(entry); PacketWriter writer = new PacketWriter(Opcodes.SMSG_GameobjectQueryResponse); writer.WriteUInt32(entry); writer.WriteInt32(go.type); writer.WriteUInt32(go.displayId); writer.WriteCString(go.name); writer.WriteUInt8(0); // name2 writer.WriteUInt8(0); // name3 writer.WriteUInt8(0); // name 4 writer.WriteCString(go.IconName); writer.WriteCString(go.castBarCaption); writer.WriteCString(go.unk1); for (int i = 0; i < 32; i++) { writer.WriteUInt32(go.RawData[i]); } writer.WriteFloat(go.size); for (int i = 0; i < 6; i++) { writer.WriteUInt32(go.questItems[i]); } writer.WriteInt32(go.unkInt32); //expansion req session.Send(writer); }
public bool Create(ulong guidlow, uint entry, uint mapid, float x, float y, float z, float ang, uint animprogress) { Relocate(x, y, z, ang); if (!IsPositionValid()) { Log.outError(LogFilter.Transport, "Transport (GUID: {0}) not created. Suggested coordinates isn't valid (X: {1} Y: {2})", guidlow, x, y); return(false); } _Create(ObjectGuid.Create(HighGuid.Transport, guidlow)); GameObjectTemplate goinfo = Global.ObjectMgr.GetGameObjectTemplate(entry); if (goinfo == null) { Log.outError(LogFilter.Sql, "Transport not created: entry in `gameobject_template` not found, guidlow: {0} map: {1} (X: {2} Y: {3} Z: {4}) ang: {5}", guidlow, mapid, x, y, z, ang); return(false); } m_goInfo = goinfo; m_goTemplateAddon = Global.ObjectMgr.GetGameObjectTemplateAddon(entry); TransportTemplate tInfo = Global.TransportMgr.GetTransportTemplate(entry); if (tInfo == null) { Log.outError(LogFilter.Sql, "Transport {0} (name: {1}) will not be created, missing `transport_template` entry.", entry, goinfo.name); return(false); } _transportInfo = tInfo; _nextFrame = 0; _currentFrame = tInfo.keyFrames[_nextFrame++]; _triggeredArrivalEvent = false; _triggeredDepartureEvent = false; if (m_goTemplateAddon != null) { SetFaction(m_goTemplateAddon.faction); SetUInt32Value(GameObjectFields.Flags, m_goTemplateAddon.flags); } m_goValue.Transport.PathProgress = 0; SetFloatValue(ObjectFields.ScaleX, goinfo.size); SetPeriod(tInfo.pathTime); SetEntry(goinfo.entry); SetDisplayId(goinfo.displayId); SetGoState(goinfo.MoTransport.allowstopping == 0 ? GameObjectState.Ready : GameObjectState.Active); SetGoType(GameObjectTypes.MapObjTransport); SetGoAnimProgress(animprogress); SetName(goinfo.name); SetWorldRotation(0.0f, 0.0f, 0.0f, 1.0f); SetParentRotation(Quaternion.WAxis); m_model = CreateModel(); return(true); }
public static GameObject Create(GameObjectTemplate template) { if (template == null) { return(null); } return(new GameObject(template)); }
public static void serializeAndWriteMissile() { GameObjectTemplate gameObject = new GameObjectTemplate(); double[] mainShapeDimensions = new double[] { 2, 0.8, 0.8 }; double mainShapeMassInKilogram = 1.0; gameObject.mainMassShapeType = "box"; gameObject.mainMass = mainShapeMassInKilogram; gameObject.mainMassDimensions = mainShapeDimensions; gameObject.meshPath = "meta:fromMainShape"; gameObject.colliders = new List <Collider>(); gameObject.colliders.Add(new Collider()); gameObject.colliders[0].localPosition = new double[] { 0, 0, 0 }; gameObject.colliders[0].localRotation = new double[] { 0, 0, 0 }; gameObject.colliders[0].size = mainShapeDimensions; gameObject.colliders[0].shapeType = "box"; gameObject.solids = new List <Solid>(); gameObject.solids.Add(new Solid()); gameObject.solids[0].size = mainShapeDimensions; gameObject.solids[0].fractionMass = mainShapeMassInKilogram; gameObject.solids[0].fractionIsotopeName = "Fe56"; gameObject.solids[0].shapeType = "box"; gameObject.solids[0].localPosition = new double[] { 0, 0, 0 }; gameObject.solids[0].localRotation = new double[] { 0, 0, 0 }; gameObject.effects = new List <Effect>(); gameObject.effects.Add(new Effect()); gameObject.effects[0].effectType = "explosion"; gameObject.effects[0].localPosition = new double[] { 0, 0, 0 }; gameObject.thrusters = new List <Thruster>(); gameObject.thrusters.Add(new Thruster()); gameObject.thrusters[0].direction = new double[] { 1, 0, 0 }; gameObject.thrusters[0].locationPosition = new double[] { -1, 0, 0 }; gameObject.thrusters[0].maximalForce = 1.0; // TODO< realistic value > gameObject.thrusters[0].tag = "accelerate+"; List <string> uriParts = new List <string>(AssemblyDirectory.Uri.Segments); uriParts.RemoveAt(0); // remove first "/" uriParts.RemoveRange(uriParts.Count - 4, 4); uriParts.AddRange(new string[] { "gameResources/", "prototypingMissile.json" }); string path = string.Join("", uriParts).Replace('/', '\\').Replace("%20", " "); string serializedJson = GameObjectTemplate.serialize(gameObject); File.WriteAllText(path, serializedJson); int debugMeHere = 1; }
public static void HandleGameObjectQueryResponse(Packet packet) { var gameObject = new GameObjectTemplate(); var entry = packet.ReadEntry("Entry"); var unk1 = packet.ReadInt32("Unk1 UInt32"); gameObject.Type = packet.ReadEnum <GameObjectType>("Type", TypeCode.Int32); gameObject.DisplayId = packet.ReadUInt32("Display ID"); var name = new string[4]; for (var i = 0; i < 4; i++) { name[i] = packet.ReadCString("Name", i); } gameObject.Name = name[0]; gameObject.IconName = packet.ReadCString("Icon Name"); gameObject.CastCaption = packet.ReadCString("Cast Caption"); gameObject.UnkString = packet.ReadCString("Unk String"); gameObject.Data = new int[32]; for (var i = 0; i < gameObject.Data.Length; i++) { gameObject.Data[i] = packet.ReadInt32("Data", i); } gameObject.Size = packet.ReadSingle("Size"); gameObject.QuestItems = new uint[packet.ReadByte("QuestItems Length")]; // correct? for (var i = 0; i < gameObject.QuestItems.Length; i++) { gameObject.QuestItems[i] = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Quest Item", i); } packet.ReadEnum <ClientType>("Expansion", TypeCode.UInt32); //var entry = packet.ReadEntry("Entry"); //if (entry.Value) // entry is masked // return; packet.ReadByte("Unk Byte"); Storage.GameObjectTemplates.Add((uint)entry.Key, gameObject, packet.TimeSpan); var objectName = new ObjectName { ObjectType = ObjectType.GameObject, Name = gameObject.Name, }; Storage.ObjectNames.Add((uint)entry.Key, objectName, packet.TimeSpan); }
public static void HandleGameObjectQueryResponse(Packet packet) { var entry = packet.ReadEntry("Entry"); if (entry.Value) // entry is masked return; GameObjectTemplate gameObject = new GameObjectTemplate { Entry = (uint)entry.Key }; int unk1 = packet.ReadInt32("Unk1 UInt32"); if (unk1 == 0) { packet.ReadByte("Unk1 Byte"); return; } gameObject.Type = packet.ReadInt32E<GameObjectType>("Type"); gameObject.DisplayID = packet.ReadUInt32("Display ID"); var name = new string[4]; for (int i = 0; i < 4; i++) name[i] = packet.ReadCString("Name", i); gameObject.Name = name[0]; gameObject.IconName = packet.ReadCString("Icon Name"); gameObject.CastCaption = packet.ReadCString("Cast Caption"); gameObject.UnkString = packet.ReadCString("Unk String"); gameObject.Data = new int?[32]; for (int i = 0; i < gameObject.Data.Length; i++) gameObject.Data[i] = packet.ReadInt32("Data", i); gameObject.Size = packet.ReadSingle("Size"); gameObject.QuestItems = new uint?[packet.ReadByte("QuestItems Length")]; for (int i = 0; i < gameObject.QuestItems.Length; i++) gameObject.QuestItems[i] = (uint)packet.ReadInt32<ItemId>("Quest Item", i); packet.ReadUInt32E<ClientType>("Expansion"); packet.ReadByte("Unk1 Byte"); Storage.GameObjectTemplates.Add(gameObject, packet.TimeSpan); ObjectName objectName = new ObjectName { ObjectType = ObjectType.GameObject, ID = entry.Key, Name = gameObject.Name }; Storage.ObjectNames.Add(objectName, packet.TimeSpan); }
private GameObject(GameObjectTemplate template) { Type |= ObjectTypes.GameObject; Entry = template.Id; GameObjectType = template.Type; DisplayId = template.DisplayId; ScaleX = template.ScaleX; _template = template; _useHandler = GetHandler(); }
void HandleGameObjectQuery(QueryGameObject packet) { QueryGameObjectResponse response = new QueryGameObjectResponse(); response.GameObjectID = packet.GameObjectID; GameObjectTemplate gameObjectInfo = Global.ObjectMgr.GetGameObjectTemplate(packet.GameObjectID); if (gameObjectInfo != null) { response.Allow = true; GameObjectStats stats = new GameObjectStats(); stats.Type = (uint)gameObjectInfo.type; stats.DisplayID = gameObjectInfo.displayId; stats.Name[0] = gameObjectInfo.name; stats.IconName = gameObjectInfo.IconName; stats.CastBarCaption = gameObjectInfo.castBarCaption; stats.UnkString = gameObjectInfo.unk1; LocaleConstant localeConstant = GetSessionDbLocaleIndex(); if (localeConstant != LocaleConstant.enUS) { GameObjectLocale gameObjectLocale = Global.ObjectMgr.GetGameObjectLocale(packet.GameObjectID); if (gameObjectLocale != null) { ObjectManager.GetLocaleString(gameObjectLocale.Name, localeConstant, ref stats.Name[0]); ObjectManager.GetLocaleString(gameObjectLocale.CastBarCaption, localeConstant, ref stats.CastBarCaption); ObjectManager.GetLocaleString(gameObjectLocale.Unk1, localeConstant, ref stats.UnkString); } } var items = Global.ObjectMgr.GetGameObjectQuestItemList(packet.GameObjectID); foreach (uint item in items) { stats.QuestItems.Add(item); } unsafe { fixed(int *ptr = gameObjectInfo.Raw.data) { for (int i = 0; i < SharedConst.MaxGOData; i++) { stats.Data[i] = ptr[i]; } } } stats.RequiredLevel = (uint)gameObjectInfo.RequiredLevel; response.Stats = stats; } SendPacket(response); }
public void LoadTransportTemplates() { uint oldMSTime = Time.GetMSTime(); SQLResult result = DB.World.Query("SELECT entry FROM gameobject_template WHERE type = 15 ORDER BY entry ASC"); if (result.IsEmpty()) { Log.outInfo(LogFilter.ServerLoading, "Loaded 0 transports templates. DB table `gameobject_template` has no transports!"); return; } uint count = 0; do { uint entry = result.Read <uint>(0); GameObjectTemplate goInfo = Global.ObjectMgr.GetGameObjectTemplate(entry); if (goInfo == null) { Log.outError(LogFilter.Sql, "Transport {0} has no associated GameObjectTemplate from `gameobject_template` , skipped.", entry); continue; } if (!CliDB.TaxiPathNodesByPath.ContainsKey(goInfo.MoTransport.taxiPathID)) { Log.outError(LogFilter.Sql, "Transport {0} (name: {1}) has an invalid path specified in `gameobject_template`.`data0` ({2}) field, skipped.", entry, goInfo.name, goInfo.MoTransport.taxiPathID); continue; } if (goInfo.MoTransport.taxiPathID == 0) { continue; } // paths are generated per template, saves us from generating it again in case of instanced transports TransportTemplate transport = new(); transport.entry = entry; GeneratePath(goInfo, transport); _transportTemplates[entry] = transport; // transports in instance are only on one map if (transport.inInstance) { _instanceTransports.Add(transport.mapsUsed.First(), entry); } ++count; } while (result.NextRow()); Log.outInfo(LogFilter.ServerLoading, "Loaded {0} transports in {1} ms", count, Time.GetMSTimeDiffToNow(oldMSTime)); }
public void Dispatch(ISession session, IPacket packet) { BinaryReader reader = packet.CreateReader(); uint id = reader.ReadUInt32(); GameObjectTemplate template = IoC.Resolve <IGameObjectTemplateRepository>().FindById(id); if (template != null) { session.SendGameObjectQueryResponce(template); } }
public static void HandleGameObjectQueryResponse(Packet packet) { var gameObject = new GameObjectTemplate(); var entry = packet.ReadEntry("Entry"); if (entry.Value) // entry is masked { return; } gameObject.Type = packet.ReadEnum <GameObjectType>("Type", TypeCode.Int32); gameObject.DisplayId = packet.ReadUInt32("Display ID"); var name = new string[4]; for (var i = 0; i < 4; i++) { name[i] = packet.ReadCString("Name", i); } gameObject.Name = name[0]; gameObject.IconName = packet.ReadCString("Icon Name"); gameObject.CastCaption = packet.ReadCString("Cast Caption"); gameObject.UnkString = packet.ReadCString("Unk String"); gameObject.Data = new int[ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_0_14333) ? 32 : 24]; for (var i = 0; i < gameObject.Data.Length; i++) { gameObject.Data[i] = packet.ReadInt32("Data", i); } if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056)) // not sure when it was added exactly - did not exist in 2.4.1 sniff { gameObject.Size = packet.ReadSingle("Size"); } gameObject.QuestItems = new uint[ClientVersion.AddedInVersion(ClientVersionBuild.V3_2_0_10192) ? 6 : 4]; if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767)) { for (var i = 0; i < gameObject.QuestItems.Length; i++) { gameObject.QuestItems[i] = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Quest Item", i); } } if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_0_14333)) { gameObject.UnknownUInt = packet.ReadUInt32("Unknown UInt32"); } Stuffing.GameObjectTemplates.TryAdd((uint)entry.Key, gameObject); }
public void OnDbLoad() { this.Template = Database.GameObjectTemplates.TryGet(this.Entry); this.Scale = this.Template.Size; if (Rotation[2] == 0 && Rotation[3] == 0) { Rotation[2] = (float)Math.Sin(this.Orientation / 2); Rotation[3] = (float)Math.Cos(this.Orientation / 2); } GridManager.Instance.AddOrGet(this, true); }
// doesn't add the entity to the entity manager public Entity buildFromTemplate(GameObjectTemplate template, SpatialVectorDouble globalPosition, SpatialVectorDouble globalVelocity) { IList <IComponent> entityComponents = new List <IComponent>(); PhysicsComponent physicsComponent = buildPhysicsComponentOfMainbody(template, globalPosition, globalVelocity); entityComponents.Add(physicsComponent); IList <ColliderComponent> colliderComponents = buildColliderComponents(template); // add physicsComponent with colliders to physics world physicsEngine.physicsAndMeshPairs.Add(new PhysicsComponentAndCollidersPair(physicsComponent, colliderComponents)); // add solids SolidCluster solidCluster = buildSolidCluster(template); if (solidCluster.solids.Count > 0) { solidResponsibility.mapping.physicsObjectIdToSolidCluster[physicsComponent.id] = solidCluster; } // add effects IList <game.responsibilities.Effect> effects = buildEffects(template); if (effects.Count > 0) { effectResponsibility.physicsObjectIdToEffects[physicsComponent.id] = effects; } // add special attributes buildSpecialAttributes(template, entityComponents); // add thrusters and recalculate thruster angular rotation cache buildThrustersAndAddToObjectAndRecalcThrusterRelatedCache(template, physicsComponent); // add rendering mesh buildAndAddRenderingMesh(template, physicsComponent); // misc // PID controller configuration readPidControllerConfiguration(template, physicsComponent.id); return(Entity.make(entityComponents)); }
static bool HandleListSpawnPointsCommand(StringArguments args, CommandHandler handler) { Player player = handler.GetSession().GetPlayer(); Map map = player.GetMap(); uint mapId = map.GetId(); bool showAll = map.IsBattlegroundOrArena() || map.IsDungeon(); handler.SendSysMessage($"Listing all spawn points in map {mapId} ({map.GetMapName()}){(showAll ? "" : " within 5000yd")}:"); foreach (var pair in Global.ObjectMgr.GetAllCreatureData()) { SpawnData data = pair.Value; if (data.spawnPoint.GetMapId() != mapId) { continue; } CreatureTemplate cTemp = Global.ObjectMgr.GetCreatureTemplate(data.Id); if (cTemp == null) { continue; } if (showAll || data.spawnPoint.IsInDist2d(player, 5000.0f)) { handler.SendSysMessage($"Type: {data.type} | SpawnId: {data.spawnId} | Entry: {data.Id} ({cTemp.Name}) | X: {data.spawnPoint.GetPositionX():3} | Y: {data.spawnPoint.GetPositionY():3} | Z: {data.spawnPoint.GetPositionZ():3}"); } } foreach (var pair in Global.ObjectMgr.GetAllGameObjectData()) { SpawnData data = pair.Value; if (data.spawnPoint.GetMapId() != mapId) { continue; } GameObjectTemplate goTemp = Global.ObjectMgr.GetGameObjectTemplate(data.Id); if (goTemp == null) { continue; } if (showAll || data.spawnPoint.IsInDist2d(player, 5000.0f)) { handler.SendSysMessage($"Type: {data.type} | SpawnId: {data.spawnId} | Entry: {data.Id} ({goTemp.name}) | X: {data.spawnPoint.GetPositionX():3} | Y: {data.spawnPoint.GetPositionY():3} | Z: {data.spawnPoint.GetPositionZ():3}"); } } return(true); }
void GeneratePath(GameObjectTemplate goInfo, TransportTemplate transport) { uint pathId = goInfo.MoTransport.taxiPathID; var path = CliDB.TaxiPathNodesByPath[pathId]; List <KeyFrame> keyFrames = transport.keyFrames; List <Vector3> splinePath = new(); List <Vector3> allPoints = new(); bool mapChange = false; for (uint i = 0; i < path.Length; ++i) { allPoints.Add(new Vector3(path[i].Loc.X, path[i].Loc.Y, path[i].Loc.Z)); } // Add extra points to allow derivative calculations for all path nodes allPoints.Insert(0, allPoints.First().lerp(allPoints[1], -0.2f)); allPoints.Add(allPoints.Last().lerp(allPoints[^ 2], -0.2f));
private static IPacket GetGameObjectQueryResponcePkt(GameObjectTemplate template) { IPacket packet = WorldPacketFactory.Create(WMSG.SMSG_GAMEOBJECT_QUERY_RESPONSE); BinaryWriter writer = packet.CreateWriter(); writer.Write(template.Id); writer.Write((uint)template.Type); writer.Write(template.DisplayId); writer.WriteCString(template.Name); writer.WriteCString(""); writer.WriteCString(""); writer.WriteCString(""); writer.WriteCString(template.IconName); writer.WriteCString(template.CastBarCaption); writer.WriteCString(""); writer.Write(template.Field0); writer.Write(template.Field1); writer.Write(template.Field2); writer.Write(template.Field3); writer.Write(template.Field4); writer.Write(template.Field5); writer.Write(template.Field6); writer.Write(template.Field7); writer.Write(template.Field8); writer.Write(template.Field9); writer.Write(template.Field10); writer.Write(template.Field11); writer.Write(template.Field12); writer.Write(template.Field13); writer.Write(template.Field14); writer.Write(template.Field15); writer.Write(template.Field16); writer.Write(template.Field17); writer.Write(template.Field18); writer.Write(template.Field19); writer.Write(template.Field20); writer.Write(template.Field21); writer.Write(template.Field22); writer.Write(template.Field23); writer.Write(template.ScaleX); writer.Write(0); writer.Write(0); writer.Write(0); writer.Write(0); return(packet); }
public static void HandleGameObjectQueryResponse(Packet packet) { var gameObject = new GameObjectTemplate(); packet.ReadByte("Unk byte"); // 128 in sniff of Guild Vault packet.ResetBitReader(); var entry = packet.ReadEntry("Entry"); packet.ReadUInt32("data size"); gameObject.Type = packet.ReadEnum <GameObjectType>("Type", TypeCode.UInt32); gameObject.DisplayId = packet.ReadUInt32("Display ID"); gameObject.Name = packet.ReadCString("Name"); packet.ReadUInt32("Unk uint32 2"); gameObject.CastCaption = packet.ReadCString("Cast Caption"); gameObject.IconName = packet.ReadCString("Icon Name"); gameObject.Data = new int[32]; for (var i = 0; i < gameObject.Data.Length; i++) { gameObject.Data[i] = packet.ReadInt32("Data", i); } gameObject.Size = packet.ReadSingle("Size"); gameObject.QuestItems = new uint[packet.ReadByte("QuestItems Length")]; // correct? for (var i = 0; i < gameObject.QuestItems.Length; i++) { gameObject.QuestItems[i] = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Quest Item", i); } packet.ReadUInt32("Unk uint32 3"); Storage.GameObjectTemplates.Add((uint)entry.Key, gameObject, packet.TimeSpan); var objectName = new ObjectName { ObjectType = ObjectType.GameObject, Name = gameObject.Name, }; Storage.ObjectNames.Add((uint)entry.Key, objectName, packet.TimeSpan); }
static bool HandleGameObjectNearCommand(StringArguments args, CommandHandler handler) { float distance = args.Empty() ? 10.0f : args.NextSingle(); uint count = 0; Player player = handler.GetPlayer(); PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_GAMEOBJECT_NEAREST); stmt.AddValue(0, player.GetPositionX()); stmt.AddValue(1, player.GetPositionY()); stmt.AddValue(2, player.GetPositionZ()); stmt.AddValue(3, player.GetMapId()); stmt.AddValue(4, player.GetPositionX()); stmt.AddValue(5, player.GetPositionY()); stmt.AddValue(6, player.GetPositionZ()); stmt.AddValue(7, distance * distance); SQLResult result = DB.World.Query(stmt); if (!result.IsEmpty()) { do { ulong guid = result.Read <ulong>(0); uint entry = result.Read <uint>(1); float x = result.Read <float>(2); float y = result.Read <float>(3); float z = result.Read <float>(4); ushort mapId = result.Read <ushort>(5); GameObjectTemplate gameObjectInfo = Global.ObjectMgr.GetGameObjectTemplate(entry); if (gameObjectInfo == null) { continue; } handler.SendSysMessage(CypherStrings.GoListChat, guid, entry, guid, gameObjectInfo.name, x, y, z, mapId); ++count; } while (result.NextRow()); } handler.SendSysMessage(CypherStrings.CommandNearobjmessage, distance, count); return(true); }
private void buildSpecialAttributes(GameObjectTemplate template, IList <IComponent> entityComponents) { if (template.specialAttributes == null) { return; } foreach (SpecialAttribute iSpecialAttribute in template.specialAttributes) { if (iSpecialAttribute.type == "withVehicleControllerComponent") // if the entity/object is with an EntityController { entityComponents.Add(new VehicleControllerComponent(attitudeAndAccelerationControlResponsibility)); } else { throw new Exception("Invalid specialAttribute " + iSpecialAttribute); } } }
/// <summary> /// Creates the object of the template (To get the prefab version use .ToPrefab() after calling this) /// </summary> public override FashionAttachTemplate Create() { // Create model GameObjectTemplate model = new GameObjectTemplate("model_fp").SetTransform(modelTrans); int num = 1; foreach (LayerInfo layer in layers) { model.AddChild(new GameObjectTemplate("layer" + num, new Create <MeshFilter>((filter) => filter.sharedMesh = layer.mesh), new Create <MeshRenderer>((render) => render.sharedMaterials = layer.materials) )); } mainObject.AddChild(model); return(this); }
PhysicsComponent buildPhysicsComponentOfMainbody(GameObjectTemplate template, SpatialVectorDouble globalPosition, SpatialVectorDouble globalVelocity) { PhysicsComponent physicsComponent; { double mass = template.mainMass; Matrix inertiaTensor; if (template.mainMassShapeType == "box") { inertiaTensor = InertiaHelper.calcInertiaTensorForCube(mass, template.mainMassDimensions[0], template.mainMassDimensions[1], template.mainMassDimensions[2]); } else { throw new Exception("Invalid mainMassShapeType " + template.mainMassShapeType); } physicsComponent = physicsEngine.createPhysicsComponent(globalPosition, globalVelocity, mass, inertiaTensor); } return(physicsComponent); }
private IList <game.responsibilities.Effect> buildEffects(GameObjectTemplate template) { IList <game.responsibilities.Effect> resultEffects = new List <game.responsibilities.Effect>(); if (template.effects == null) { return(resultEffects); } foreach (serialization.Effect iEffect in template.effects) { if (iEffect.effectType == "explosion") { resultEffects.Add(game.responsibilities.Effect.makeExplosion(new SpatialVectorDouble(iEffect.localPosition))); } else { throw new Exception("Invalid effectType " + iEffect.effectType); } } return(resultEffects); }
void HandleGameObjectQuery(QueryGameObject packet) { GameObjectTemplate info = Global.ObjectMgr.GetGameObjectTemplate(packet.GameObjectID); if (info != null) { if (!WorldConfig.GetBoolValue(WorldCfg.CacheDataQueries)) { info.InitializeQueryData(); } QueryGameObjectResponse queryGameObjectResponse = info.QueryData; LocaleConstant loc = GetSessionDbLocaleIndex(); if (loc != LocaleConstant.enUS) { GameObjectLocale gameObjectLocale = Global.ObjectMgr.GetGameObjectLocale(queryGameObjectResponse.GameObjectID); if (gameObjectLocale != null) { ObjectManager.GetLocaleString(gameObjectLocale.Name, loc, ref queryGameObjectResponse.Stats.Name[0]); ObjectManager.GetLocaleString(gameObjectLocale.CastBarCaption, loc, ref queryGameObjectResponse.Stats.CastBarCaption); ObjectManager.GetLocaleString(gameObjectLocale.Unk1, loc, ref queryGameObjectResponse.Stats.UnkString); } } SendPacket(queryGameObjectResponse); } else { Log.outDebug(LogFilter.Network, $"WORLD: CMSG_GAMEOBJECT_QUERY - Missing gameobject info for (ENTRY: {packet.GameObjectID})"); QueryGameObjectResponse response = new QueryGameObjectResponse(); response.GameObjectID = packet.GameObjectID; response.Guid = packet.Guid; SendPacket(response); } }