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 GameObject(Model model, GameObjectStats objectStats) { Model = model; Ambient = new List<float>(); Opacity=new List<float>(); Transparency=new List<float>(); DiffuseColor=new List<Vector3>(); DiffuseFactor=new List<float>(); Specular=new List<Vector3>(); SpecularFactor=new List<float>(); Shininess = new List<Vector3>(); Opacity = new List<float>(); Scale = Vector3.One; position = new Vector3(105, 0, 80); EffectList = new List<IObjectEffect>(); foreach (string effectName in objectStats.Effects) { IObjectEffect effect = EffectFactory.GetEffectByName(effectName); effect.GameObject = this; EffectList.Add(effect); } //tworzymy obiekty zależne od aktualnie ładowanego... if(children == null) { children = new List<GameObject>(); } foreach (SubElement subElement in objectStats.SubElements) { GameObject gameObject = subElement.GameObject; gameObject.Position = subElement.Position; gameObject.Angle = subElement.Rotation; gameObject.Scale = subElement.Scale; gameObject.Parent = this; children.Add(gameObject); } visible = true; }
public void LoadGameObject() { Log.Message(LogType.DB, "Loading gameobjects..."); SQLResult result = DB.World.Select("SELECT * FROM gameobject_stats"); Parallel.For(0, result.Count, r => { GameObjectStats Stats = new GameObjectStats { Id = result.Read <int>(r, "Id"), Type = result.Read <GameObjectType>(r, "Type"), DisplayInfoId = result.Read <int>(r, "DisplayInfoId"), Name = result.Read <string>(r, "Name"), IconName = result.Read <string>(r, "IconName"), CastBarCaption = result.Read <string>(r, "CastBarCaption"), Size = result.Read <float>(r, "Size"), ExpansionRequired = result.Read <int>(r, "ExpansionRequired") }; for (int i = 0; i < Stats.Data.Capacity; i++) { Stats.Data.Add(result.Read <int>(r, "Data", i)); } for (int i = 0; i < Stats.QuestItemId.Capacity; i++) { var questItem = result.Read <int>(r, "QuestItemId", i); if (questItem != 0) { Stats.QuestItemId.Add(questItem); } } Add(new GameObject { Stats = Stats }); }); Log.Message(LogType.DB, "Loaded {0} gameobjects.", GameObjects.Count); Log.Message(); }
// Use this for initialization void Start() { animator = GetComponent <Animator>(); GameObject[,] map = AddingMovingIndicatorTile.map; for (int i = 0; i < map.GetLength(0); i++) { for (int j = 0; j < map.GetLength(1); j++) { if (map[i, j].transform.position == transform.position) { TileIndicator tileIndicator = map[i, j].GetComponent <TileIndicator>(); tileIndicator.gameObjectInMap = this; //Set up stats gameObjectStats = new GameObjectStats(); gameObjectStats.name = "Cat"; gameObjectStats.movement = 4; gameObjectStats.attackRange = 1; Debug.Log(map.GetLength(0)); break; } } } }
public GameObject(int id) { SQLResult result = DB.World.Select("SELECT * FROM gameobject_stats WHERE id = ?", id); if (result.Count != 0) { Stats = new GameObjectStats(); Stats.Id = result.Read <Int32>(0, "Id"); Stats.Type = result.Read <Int32>(0, "Type"); Stats.Flags = result.Read <Int32>(0, "Flags"); Stats.DisplayInfoId = result.Read <Int32>(0, "DisplayInfoId"); Stats.Name = result.Read <String>(0, "Name"); Stats.IconName = result.Read <String>(0, "IconName"); Stats.CastBarCaption = result.Read <String>(0, "CastBarCaption"); for (int i = 0; i < Stats.Data.Capacity; i++) { Stats.Data.Add(result.Read <Int32>(0, "Data", i)); } Stats.Size = result.Read <Single>(0, "Size"); for (int i = 0; i < Stats.QuestItemId.Capacity; i++) { var questItem = result.Read <Int32>(0, "QuestItemId", i); if (questItem != 0) { Stats.QuestItemId.Add(questItem); } } Stats.ExpansionRequired = result.Read <Int32>(0, "ExpansionRequired"); } }
public GameObjectStats GetObjectStats(string name) { if (xDocument == null) { throw new NullReferenceException("GameObjectStatsReader was not initialized"); } GameObjectStats gameObjectStats = null; foreach (XElement xElement in xDocument.Root.Elements()) { if (xElement.Attribute("Name").Value == name) { float fgetter; int igetter; bool bgetter; switch (xElement.Attribute("Type").Value) { case "GameObject": if (gameObjectStats == null) { gameObjectStats = new GameObjectStats(); } gameObjectStats.Name = xElement.Attribute("Name").Value; GameObjectFactory.ObjectClass objectClass; GameObjectFactory.ObjectClass.TryParse(xElement.Attribute("Type").Value, out objectClass); gameObjectStats.Type = objectClass; foreach(XElement xel in xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "Effect")) { gameObjectStats.Effects.Add(xel.Value); } foreach (XElement xel in xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "SubModel")) { Vector3 pos, rot, sc; if(xel.Attribute("Position") != null) { ParseVector3(xel.Attribute("Position").Value, out pos); } else { pos = Vector3.Zero; } if (xel.Attribute("Rotation") != null) { ParseVector3(xel.Attribute("Rotation").Value, out rot); } else { rot = Vector3.Zero; } if (xel.Attribute("Scale") != null) { ParseVector3(xel.Attribute("Scale").Value, out sc); } else { sc = Vector3.One; } gameObjectStats.SubElements.Add(new SubElement(xel.Value, pos, rot, sc)); } break; case "Unit": if (gameObjectStats == null) { gameObjectStats = new UnitStats(); } float.TryParse( xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "Speed").First().Value, out fgetter); ((UnitStats)gameObjectStats).Speed = fgetter; float.TryParse( xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "TurnRadius").First().Value, out fgetter); ((UnitStats)gameObjectStats).TurnRadius = fgetter; goto case "GameObject"; case "Infantry": if (gameObjectStats == null) { gameObjectStats = new InfantryStats(); } goto case "Unit"; case "Vehicle": if (gameObjectStats == null) { gameObjectStats = new VehicleStats(); } Int32.TryParse( xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "FrontWheelsCount").First().Value, out igetter); ((VehicleStats)gameObjectStats).FrontWheelCount = igetter; Int32.TryParse( xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "RearWheelsCount").First().Value, out igetter); ((VehicleStats)gameObjectStats).RearWheelCount = igetter; Int32.TryParse( xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "DoorCount").First().Value, out igetter); ((VehicleStats)gameObjectStats).DoorCount = igetter; Boolean.TryParse( xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "HasTurret").First().Value, out bgetter); ((VehicleStats)gameObjectStats).HasTurret = bgetter; if (((VehicleStats)gameObjectStats).HasTurret) { Int32.TryParse( xElement.Elements().Where(s => s.Attribute("AttributeName").Value == "WaterSourceCount").First().Value, out igetter); ((VehicleStats)gameObjectStats).WaterSourceCount = igetter; } else { ((VehicleStats)gameObjectStats).WaterSourceCount = 0; } goto case "Unit"; case "Building": if (gameObjectStats == null) { gameObjectStats = new BuildingStats(); } goto case "GameObject"; case "StaticObject": if (gameObjectStats == null) { gameObjectStats = new StaticObjectStats(); } goto case "GameObject"; case "Civilian": if (gameObjectStats == null) { gameObjectStats = new CivilianStats(); } goto case "GameObject"; } break; } } if(gameObjectStats == null) { throw new ArgumentException("Invalid Object name"); } return gameObjectStats; }
public static void HandleQueryGameObject(ref PacketReader packet, ref WorldClass session) { byte[] guidMask = { 4, 6, 7, 5, 3, 2, 1, 0 }; byte[] guidBytes = { 0, 2, 3, 5, 6, 1, 4, 7 }; BitUnpack BitUnpack = new BitUnpack(packet); var hasData = false; var id = packet.Read <int>(); var guid = BitUnpack.GetPackedValue(guidMask, guidBytes); PacketWriter queryGameObjectResponse = new PacketWriter(ServerMessage.QueryGameObjectResponse); BitPack BitPack = new BitPack(queryGameObjectResponse); GameObject gObject = DataMgr.FindGameObject(id); if (hasData = (gObject != null)) { GameObjectStats stats = gObject.Stats; BitPack.Write(hasData); BitPack.Flush(); queryGameObjectResponse.WriteInt32(stats.Id); queryGameObjectResponse.WriteInt32(0); queryGameObjectResponse.WriteInt32(stats.Type); queryGameObjectResponse.WriteInt32(stats.DisplayInfoId); queryGameObjectResponse.WriteCString(stats.Name); for (int i = 0; i < 3; i++) { queryGameObjectResponse.WriteCString(""); } queryGameObjectResponse.WriteCString(stats.IconName); queryGameObjectResponse.WriteCString(stats.CastBarCaption); queryGameObjectResponse.WriteCString(""); foreach (var v in stats.Data) { queryGameObjectResponse.WriteInt32(v); } queryGameObjectResponse.WriteFloat(stats.Size); queryGameObjectResponse.WriteUInt8((byte)stats.QuestItemId.Count); foreach (var v in stats.QuestItemId) { queryGameObjectResponse.WriteInt32(v); } queryGameObjectResponse.WriteInt32(stats.ExpansionRequired); var size = (uint)queryGameObjectResponse.BaseStream.Length - 13; queryGameObjectResponse.WriteUInt32Pos(size, 9); session.Send(ref queryGameObjectResponse); } else { BitPack.Write(hasData); Log.Message(LogType.DEBUG, "Gameobject (Id: {0}) not found.", id); } }