/// <summary> /// </summary> /// <param name="pooledIn"> /// </param> /// <param name="parent"> /// </param> /// <param name="id"> /// </param> public PooledObject(Identity parent, Identity id) { this.Identity = id; this.Parent = parent; Pool.Instance.AddObject(parent, this); LogUtil.Debug( DebugInfoDetail.Pool, "Created new object " + id.ToString(true) + " of " + parent.ToString(true)); }
public static ICharacter InstantiateMobSpawn( DBMobSpawn mob, DBMobSpawnStat[] stats, IController npccontroller, IPlayfield playfield) { if (playfield != null) { Identity mobId = new Identity() { Type = IdentityType.CanbeAffected, Instance = mob.Id }; if (Pool.Instance.GetObject(playfield.Identity, mobId) != null) { throw new Exception("Object " + mobId.ToString(true) + " already exists!!"); } Character cmob = new Character(playfield.Identity, mobId, npccontroller); cmob.Read(); cmob.Playfield = playfield; cmob.Coordinates(new Coordinate() { x = mob.X, y = mob.Y, z = mob.Z }); cmob.RawHeading = new Quaternion(mob.HeadingX, mob.HeadingY, mob.HeadingZ, mob.HeadingW); cmob.Name = mob.Name; cmob.FirstName = ""; cmob.LastName = ""; foreach (DBMobSpawnStat stat in stats) { cmob.Stats.SetBaseValueWithoutTriggering(stat.Stat, (uint)stat.Value); } cmob.Stats.SetBaseValueWithoutTriggering((int)StatIds.visualprofession, cmob.Stats[StatIds.profession].BaseValue); // initiate affected stats calculation int temp = cmob.Stats[StatIds.level].Value; temp = cmob.Stats[StatIds.agility].Value; temp = cmob.Stats[StatIds.headmesh].Value; cmob.MeshLayer.AddMesh(0, cmob.Stats[StatIds.headmesh].Value, 0, 4); cmob.SocialMeshLayer.AddMesh(0, cmob.Stats[StatIds.headmesh].Value, 0, 4); List<MobSpawnWaypoint> waypoints = MessagePackZip.DeserializeData<MobSpawnWaypoint>(mob.Waypoints.ToArray()); foreach (MobSpawnWaypoint wp in waypoints) { Waypoint mobwp = new Waypoint(); mobwp.Position.x = wp.X; mobwp.Position.y = wp.Y; mobwp.Position.z = wp.Z; mobwp.Running = wp.WalkMode == 1; cmob.Waypoints.Add(mobwp); } npccontroller.Character = cmob; if (cmob.Waypoints.Count > 2) { cmob.Controller.State = CharacterState.Patrolling; } cmob.DoNotDoTimers = false; return cmob; } return null; }
public bool Add(Identity from, IItem item) { if (from.Equals(this.Shopper)) { this.vendorsBag.Add(this.vendorsBag.FindFreeSlot(), item); LogUtil.Debug(DebugInfoDetail.Shopping, "Added Item from character " + from.ToString(true)); } else { this.charactersBag.Add(from.Instance); LogUtil.Debug(DebugInfoDetail.Shopping, "Added Item from shop on position " + from.ToString(true)); } // For now no invalid trades return true; }