Exemplo n.º 1
0
        private static ActorMeta CreateActorMeta(DiaObject diaObject, ACD acd, int actorSNO, ActorType actorType)
        {
            using (new PerformanceLogger("CreateActorMeta"))
            {
                ActorMeta actorMeta;

                // We only care about having accurate information on Units and Gizmos.
                // Everything else can just return the default.

                //if (actorType == ActorType.Monster && diaObject is DiaUnit || 
                //    actorType == ActorType.Gizmo && diaObject is DiaGizmo || 
                //    actorType == ActorType.Player)
                //{
                    actorMeta = new ActorMeta(diaObject, acd, actorSNO, actorType);
               
                    if (Trinity.Settings.Advanced.ExportNewActorMeta && actorMeta.IsValid && !actorMeta.IsPartial)
                    {
                        Logger.Log("Exporting ActorMeta for {0} ({1})", acd.Name, actorSNO);
                        WriteToLog(actorMeta);
                    }
                //}
                //else if (actorType == ActorType.Player)
                //{
                //    actorMeta = new ActorMeta(diaObject, acd, actorSNO, actorType);
                //}
                //else
                //{
                //    actorMeta = new ActorMeta();
                //}

                ReferenceActorMeta.Add(actorSNO, actorMeta);

                return actorMeta;
            }
        }
Exemplo n.º 2
0
        public static SpriteSheet CreateSpriteSheet(ActorType actorType)
        {
            if (_sheets == null)
                throw new InvalidOperationException("_sheets was not initialized -- need to call SpriteSheetFactory.Initialize");

            return _sheets[actorType].Invoke();
        }
Exemplo n.º 3
0
        public static GameplayStats DefaultStats(ActorType actorType)
        {
            if (actorType == ActorType.Imp)
            {
                return new GameplayStats()
                           {
                               Health = 500,
                               Essence = 100,
                               AD = 40,
                               DP = 15,
                               Armor = 20,
                               DR = 15,
                               Speed = 6,
                               MovementRange = 3,
                               MaximumHeightCanMove = 1
                           };
            }
            else if (actorType == ActorType.Caco)
            {
                return new GameplayStats()
                           {
                               Health = 300,
                               Essence = 175,
                               AD = 20,
                               DP = 40,
                               Armor = 12,
                               DR = 18,
                               Speed = 7,
                               MovementRange = 5,
                               MaximumHeightCanMove = 5
                           };
            }

            return Statsless();
        }
Exemplo n.º 4
0
        public static Func<Vector3, Vector3, ActorBase> GetSpawnMethod(ActorType actorType)
        {
            if (!_initialized)
                Initialize();

            return _spawnMethods[actorType];
        }
Exemplo n.º 5
0
        public Actor Spawn(ActorType actorType)
        {
            Stack<GameObject> pool = poolDictionary[actorType];
            if( pool.Count == 0 )
            {
                Debug.Log("empty pool"+actorType);
                return null;
            }
            GameObject spawn = pool.Pop();
            spawn.transform.parent = null;
            Actor actor = spawn.GetComponent<Actor>();
            Bounds bounds = World.Instance.GetLiveableArea(actor.liveableArea);
            float xPos = bounds.center.x;
            float yPos = Random.Range(bounds.min.y, bounds.max.y);
            float zPos = Random.Range(bounds.min.z, bounds.max.z);
            Vector3 startPos = new Vector3(xPos, yPos, zPos);
            Vector3 midPos = startPos;
            midPos.z = 0;
            actor.transform.position = startPos;
            string actorTypeName = actorType.ToString();
            if( actorTypeName.StartsWith("FISH"))
            {
                actor.transform.LookAt(midPos);
            }
            spawn.SetActive(true);

            actor.AfterSpawn();

            return actor;
        }
        internal static StreamSubscriptionSpecification From(ActorType type, StreamSubscriptionAttribute attribute)
        {
            if (string.IsNullOrWhiteSpace(attribute.Source))
                throw InvalidSpecification(type, "has null or whitespace only value of Source");

            if (string.IsNullOrWhiteSpace(attribute.Target))
                throw InvalidSpecification(type, "has null or whitespace only value of Target");

            if (attribute.Filter != null && string.IsNullOrWhiteSpace(attribute.Filter))
                throw InvalidSpecification(type, "has whitespace only value of Filter");

            var parts = attribute.Source.Split(new[] {":"}, 2, StringSplitOptions.None);
            if (parts.Length != 2)
                throw InvalidSpecification(type, $"has invalid Source specification: {attribute.Source}");

            var provider = parts[0];
            var source   = parts[1];
            var target   = attribute.Target;
            var filter   = attribute.Filter;

            var isRegex  = source.StartsWith("/") && 
                           source.EndsWith("/");
            if (!isRegex)
                return new MatchExact(provider, source, target, type, filter);

            var pattern = source.Substring(1, source.Length - 2);
            return new MatchPattern(provider, pattern, target, type, filter);
        }
Exemplo n.º 7
0
 // get nearest target of targetType
 public static Actor GetNearestTarget(World world, Actor attacker, Vector3D centerPosition, float range, ActorType targetType = ActorType.Monster)
 {
     Actor result = null;
     List<Actor> actors = world.QuadTree.Query<Actor>(new Circle(centerPosition.X, centerPosition.Y, range));
     if (actors.Count > 1)
     {
         float distanceNearest = range; // max. range
         float distance = 0f;
         foreach (var target in actors.Where(target => ((target.ActorType == targetType) && (target != attacker) && !target.Attributes[GameAttribute.Is_NPC])))
         {
             if ((target.World == null) || (world.GetActorByDynamicId(target.DynamicID) == null))
             {
                 // leaving world
                 continue;
             }
             distance = ActorUtils.GetDistance(centerPosition, target.Position);
             if ((result == null) || (distance < distanceNearest))
             {
                 result = target;
                 distanceNearest = distance;
             }
         }
     }
     return result;
 }
 //���һ������
 public static ActorData getActorData(string id, string groupid, ActorType type, ActorPro pro)
 {
     ActorData data = new ActorData(id);
     data.GroupID = groupid;
     data.ActorType = type;
     data.ActorPro = pro;
     return data;
 }
 public Vector3 GetMovesOffset(ActorType targetType)
 {
     switch (targetType)
     {
         case ActorType.Enemy:return new Vector3(0,0,-this.GridZLength/2);
         case ActorType.Player: return new Vector3(0, 0, this.GridZLength / 2);
     }
     return Vector3.zero;
 }
        StreamSubscriptionSpecification(string provider, string source, string target, ActorType actor, string filter)
        {
            Provider    = provider;
            this.source = source;
            this.target = target;

            this.filter = BuildFilter(filter, actor);
            receiver    = BuildReceiver(target, actor);
        }
Exemplo n.º 11
0
        public static void Register(ActorType type)
        {
            var isActor  = type.Interface.GetCustomAttribute<ActorAttribute>()  != null;
            var isWorker = type.Interface.GetCustomAttribute<WorkerAttribute>() != null;

            if (isActor && isWorker)
                throw new InvalidOperationException(
                    $"A type cannot be configured to be both Actor and Worker: {type}");

            factories.Add(type, isWorker ? GetWorkerFactory()  : GetActorFactory(type));
        }
Exemplo n.º 12
0
        internal static ActorPrototype Of(ActorType type)
        {
            var prototype = cache.Find(type);

            if (prototype == null)
                throw new InvalidOperationException(
                    $"Can't find implementation for actor '{type}'." +
                     "Make sure you've registered assembly containing this type");

            return prototype;
        }
Exemplo n.º 13
0
        public Actor(MpqFile file)
        {
            var stream = file.Open();
            Header = new Header(stream);

            this.Int0 = stream.ReadValueS32();
            this.Type = (ActorType)stream.ReadValueS32();
            this.ApperanceSNO = stream.ReadValueS32();
            this.PhysMeshSNO = stream.ReadValueS32();
            this.Cylinder = new AxialCylinder(stream);
            this.Sphere = new Sphere(stream);
            this.AABBBounds = new AABB(stream);

            var tagmap = stream.GetSerializedDataPointer(); // we need to read tagmap. /raist.
            stream.Position += (2*4);

            this.AnimSetSNO = stream.ReadValueS32();
            this.MonsterSNO = stream.ReadValueS32();

            var msgTriggeredEvents = stream.GetSerializedDataPointer();

            this.Int1 = stream.ReadValueS32();
            stream.Position += (3*4);
            this.V0 = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());

            this.Looks = new WeightedLook[8];
            for (int i = 0; i < 8; i++)
            {
                this.Looks[i] = new WeightedLook(stream);
            }

            this.PhysicsSNO = stream.ReadValueS32();
            this.Int2 = stream.ReadValueS32();
            this.Int3 = stream.ReadValueS32();
            this.Float0 = stream.ReadValueF32();
            this.Float1 = stream.ReadValueF32();
            this.Float2 = stream.ReadValueF32();

            this.ActorCollisionData = new int[17]; // Was 68/4 - Darklotus 
            for (int i = 0; i < 17; i++)
            {
                this.ActorCollisionData[i] = stream.ReadValueS32();
            }

            this.InventoryImages = new int[10]; //Was 5*8/4 - Darklotus
            for (int i = 0; i < 10; i++)
            {
                this.InventoryImages[i] = stream.ReadValueS32();
            }

            // Updated based on BoyC's 010editoer template, looks like some data at the end still isnt parsed - Darklotus
            stream.Close();
        }
Exemplo n.º 14
0
        public static ActorMeta GetOrCreateActorMeta(DiaObject diaObject, ACD acd, int actorSNO, ActorType actorType)
        {
            using (new PerformanceLogger("GetOrCreateActorMeta"))
            {
                ActorMeta actorMeta;

                if (!ReferenceActorMeta.TryGetValue(actorSNO, out actorMeta))
                {
                    actorMeta = CreateActorMeta(diaObject, acd, actorSNO, actorType);
                }

                return actorMeta;
            }
        }
Exemplo n.º 15
0
        public static string GetActorPath( ActorType actorType, int hospitalId = 0 )
        {
            string path;

            switch ( actorType )
            {
                case ActorType.Dashboard:
                    path = $"{PathPrefix}/user/{DashboardActorName}";
                    break;

                case ActorType.Commander:
                    path = $"{PathPrefix}/user/{MediWatchCommanderActorName}";
                    break;

                case ActorType.Coordinator:
                    if ( hospitalId <= 0 ) throw new ArgumentOutOfRangeException( "hospitalId" );
                    path = $"{PathPrefix}/user/{MediWatchCommanderActorName}/{GetActorCoordinatorName( hospitalId )}";
                    break;

                case ActorType.Fetcher:
                    if (hospitalId <= 0) throw new ArgumentOutOfRangeException("hospitalId");
                    path = $"{PathPrefix}/user/{MediWatchCommanderActorName}/{GetActorCoordinatorName(hospitalId)}/{HospitalEventFetcherActorName}";
                    break;

                case ActorType.StatAvgTimeToSeeADoctorActor:
                    if ( hospitalId <= 0 ) throw new ArgumentOutOfRangeException( "hospitalId" );
                    path = $"{PathPrefix}/user/{MediWatchCommanderActorName}/{GetActorCoordinatorName( hospitalId )}/{StatAvgTimeToSeeADoctorActorName}";
                    break;

                case ActorType.StatAvgAppointmentDurationActor:
                    if ( hospitalId <= 0 ) throw new ArgumentOutOfRangeException( "hospitalId" );
                    path = $"{PathPrefix}/user/{MediWatchCommanderActorName}/{GetActorCoordinatorName( hospitalId )}/{StatAvgAppointmentDurationActorName}";
                    break;

                case ActorType.StatDiseaseActor:
                    if (hospitalId <= 0) throw new ArgumentOutOfRangeException("hospitalId");
                    path = $"{PathPrefix}/user/{MediWatchCommanderActorName}/{GetActorCoordinatorName(hospitalId)}/{StatDiseaseActorName}";
                    break;

                case ActorType.StatEstimatedTimeToSeeADoctorActor:
                    if (hospitalId <= 0) throw new ArgumentOutOfRangeException("hospitalId");
                    path = $"{PathPrefix}/user/{MediWatchCommanderActorName}/{GetActorCoordinatorName(hospitalId)}/{StatEstimatedTimeToSeeADoctorActorName}";
                    break;

                default:
                    throw new ArgumentOutOfRangeException( "actorType" );
            }

            return path;
        }
Exemplo n.º 16
0
 public EntityTypeDescriptor(string name, bool isStatic, Type modelType, ActorType[] restrictTo, Type interfaceType, IEnumerable<OperationDescriptor> operations, IEnumerable<PropertyDescriptor> properties, IEnumerable<EventDescriptor> events)
 {
   this.Name = name;
   this.Static = isStatic;
   this.Model = modelType;
   this.RestrictTo = restrictTo;
   this.Interface = interfaceType;
   this.Operations = (IDictionary<string, OperationDescriptor>) new Dictionary<string, OperationDescriptor>();
   foreach (OperationDescriptor operationDescriptor in operations)
     this.Operations.Add(operationDescriptor.Name, operationDescriptor);
   this.Properties = (IDictionary<string, PropertyDescriptor>) new Dictionary<string, PropertyDescriptor>();
   foreach (PropertyDescriptor propertyDescriptor in properties)
     this.Properties.Add(propertyDescriptor.Name, propertyDescriptor);
   this.Events = (IDictionary<string, EventDescriptor>) new Dictionary<string, EventDescriptor>();
   foreach (EventDescriptor eventDescriptor in events)
     this.Events.Add(eventDescriptor.Name, eventDescriptor);
 }
        static Func<object, bool> BuildFilter(string filter, ActorType actor, ActorPrototype prototype)
        {
            if (filter == null)
                return item => prototype.DeclaresHandlerFor(item.GetType());

            if (filter == "*")
                return item => true;

            if (!filter.EndsWith("()"))
                throw new InvalidOperationException("Filter string value is missing '()' function designator");

            var method = GetStaticMethod(filter, actor.Implementation);
            if (method == null)
                throw new InvalidOperationException("Filter function should be a static method");

            return (Func<object, bool>)method.CreateDelegate(typeof(Func<object, bool>));
        }
Exemplo n.º 18
0
        static Func<string, object> GetActorFactory(ActorType type)
        {
            var factory = GrainFactory();

            var attribute = type.Interface.GetCustomAttribute<ActorAttribute>()
                            ?? new ActorAttribute();

            switch (attribute.Placement)
            {
                case Placement.Random:
                    return id => factory.GetGrain<IA0>(id);;
                case Placement.PreferLocal:
                    return id => factory.GetGrain<IA1>(id);;
                case Placement.DistributeEvenly:
                    return id => factory.GetGrain<IA2>(id);;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 19
0
 public static bool CanInteract(ActorType a, ActorType b)
 {
     if( IsFish(a) )
     {
         return IsFish(b) || IsHook(b) || IsFood(b);
     }
     if( IsHook(a) )
     {
         return IsFish(b) || IsBoat(b);
     }
     if( IsFood(a) )
     {
         return IsFish(b);
     }
     if( IsBoat(a) )
     {
         return IsHook(b);
     }
     return false;
 }
    public void Assign(ActorStatusComponent values)
    {
        Type = values.Type;
        BaseMaxHP = values.BaseMaxHP;
        BaseHP = values.BaseHP;
        BaseMoveSpeed = values.BaseMoveSpeed;
        BaseAttackSpeed = values.BaseAttackSpeed;
        BaseDamage = values.BaseDamage;

        MaxHPModifiers = values.MaxHPModifiers;
        HPModifiers = values.HPModifiers;
        MoveSpeedModifiers = values.MoveSpeedModifiers;
        AttackSpeedModifiers = values.AttackSpeedModifiers;
        DamageModifiers = values.DamageModifiers;

        MaxHP = values.MaxHP;
        HP = values.HP;
        MoveSpeed = values.MoveSpeed;
        AttackSpeed = values.AttackSpeed;
        Damage = values.Damage;
    }
Exemplo n.º 21
0
        private uint GetNewActorID(ActorType type)
        {
            // get an unused actorID
            uint newID = 0;
            uint startID = 0;

            if (type == ActorType.PC) {
                newID = this.nextPcId;
                startID = this.nextPcId;
            }
            else {
                if (type == ActorType.NPC)
                {
                    newID = this.nextNpcId;
                    startID = this.nextNpcId;
                }
                else
                {
                    newID = this.nextItemId;
                    startID = this.nextItemId;
                }
            }

            while (this.actorsByID.ContainsKey(newID))
            {
                newID++;

                if(newID >= ID_BORDER2 && type == ActorType.PC)
                    newID = 1;

                if(newID >= UInt32.MaxValue)
                    newID = ID_BORDER + 1;

                if (newID == startID) return 0;
            }

            if (type == ActorType.PC)
                this.nextPcId = newID + 1;
            else
                if(type==ActorType .NPC)
                    this.nextNpcId = newID + 1;
                else
                    this.nextItemId = newID + 1;

            return newID;
        }
        static Func<IActorSystem, string, Func<object, Task>> BuildReceiver(string target, ActorType type)
        {
            if (!target.EndsWith("()"))
            {
                return (system, id) =>
                {
                    var receiver = system.ActorOf(type, id);
                    return receiver.Tell;
                };
            }

            var method = GetStaticMethod(target, type.Implementation);
            if (method == null)
                throw new InvalidOperationException("Target function should be a static method");

            var selector = (Func<object, string>)method.CreateDelegate(typeof(Func<object, string>));
            return (system, id) => (item => system.ActorOf(type, selector(item)).Tell(item));
        }
 static Exception InvalidSpecification(ActorType type, string error)
 {
     string message = $"StreamSubscription attribute defined on '{type}' {error}";
     return new InvalidOperationException(message);
 }
 public MatchPattern(string provider, string source, string target, ActorType actor, string filter)
     : base(provider, source, target, actor, filter)
 {
     matcher = new Regex(source, RegexOptions.Compiled);
     generator = new Regex(@"(?<placeholder>\{[^\}]+\})", RegexOptions.Compiled);
 }
 public MatchExact(string provider, string source, string target, ActorType actor, string filter)
     : base(provider, source, target, actor, filter)
 {}
 internal static IEnumerable<StreamSubscriptionSpecification> From(ActorType type)
 {
     return type.Implementation
                .GetCustomAttributes<StreamSubscriptionAttribute>(inherit: true)
                .Select(a => From(type, a));
 }
Exemplo n.º 27
0
 internal static void Register(ActorType type)
 {
     cache.Add(type, Define(type.Implementation));
 }
Exemplo n.º 28
0
 ActorPrototype(ActorType type)
 {
     gc = new GC(type.Implementation);
     dispatcher = new Dispatcher(type.Implementation);
     this.type = type;
 }
Exemplo n.º 29
0
        public static ActorCommonData get_SelectedAtackableAcd(out double distance, out ActorType type)
        {
            distance = 0;
            type = ActorType.Invalid;

            try
            {


                
                var ListB = Engine.Current.ObjectManager.x9E0_PlayerInput.Dereference().x00_ListB_Of_ActorId.ToList();
                

                if (ListB.Count() > 0)
                {
                    var selectedActorId = ListB.ToList()[0];

                    
                    var selectedtype = Engine.Current.ObjectManager.x9E0_PlayerInput.Dereference().x14_StructStart_Min56Bytes;

                    if (selectedtype == 44580)
                    {

                        List<A_Collector.ACD> acdcontainer;
                        lock (A_Collection.Environment.Actors.AllActors)
                            acdcontainer = A_Collection.Environment.Actors.AllActors.ToList();

                        var acd = acdcontainer.FirstOrDefault(x => x._ACD.x08C_ActorId == selectedActorId);

                        if (acd != null)
                        {
                            
                            distance = acd.Distance;
                            type = acd._ACD.x184_ActorType;
                            
                            return acd._ACD;
                        }


                    }
                }

                return null;

            }
            catch { return null; }
        }
Exemplo n.º 30
0
 static ActorPrototype CreatePrototype(ActorType type) => new ActorPrototype(type);