Exemple #1
0
        protected void Initialize(IServiceProvider provider)
        {
            StreamProviderManager = provider.GetRequiredService <IStreamProviderManager>();
            GrainFactory          = provider.GetRequiredService <IGrainFactory>();

            ActorInterface.Bind(GrainFactory);
        }
Exemple #2
0
            public void Version_attribute()
            {
                var @interface = ActorInterface.Of <TestVersionActor>();
                var attribute  = AssertHasCustomAttribute <VersionAttribute>(@interface.Grain);

                Assert.That(attribute.Version, Is.EqualTo(22));
            }
        public Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            var factory = providerRuntime.GrainFactory;

            ActorInterface.Bind(factory);
            return(TaskDone.Done);
        }
Exemple #4
0
        public ActorRef(SerializationInfo info, StreamingContext context)
        {
            var value = (string)info.GetValue("path", typeof(string));

            Path       = ActorPath.Deserialize(value);
            endpoint   = ActorEndpoint.Proxy(Path);
            @interface = ActorInterface.Of(Path);
        }
    void killActiveActors()
    {
        List <GameObject> activeActors = getActiveActors();

        foreach (GameObject actorObj in activeActors)
        {
            ActorInterface actor = actorObj.GetComponent <ActorInterface>();
            actor.removeHealth(actor.getHealth() + 1f);
        }
    }
    void playerEnemyCollision(Collider2D col)
    {
        ActorInterface enemy = col.transform.parent.GetComponent <ActorInterface>();

        enemy.removeHealth(bulletContainer.getBulletDamage());
        if (enemy.getHealth() <= 0)
        {
            parent.GetComponent <PlayerController>().killedEnemy(parentWeapon);
        }
        freeBullet();
    }
 int getActorIndex(ActorInterface actor)
 {
     for (int i = 0; i < spawnedActors.Count; i++)
     {
         if (actor == spawnedActors[i])
         {
             return(i);
         }
     }
     return(-1);
 }
    void removeActorFromList(ActorInterface actor)
    {
        if (currentActors == 0)
        {
            throw new System.Exception("Cannot remove actor from empty list");
        }
        currentActors--;
        int index = getActorIndex(actor);

        spawnedActors[index] = null;
    }
Exemple #9
0
        /// <inheritdoc />
        public ActorRef ActorOf(ActorPath path)
        {
            if (path == ActorPath.Empty)
            {
                throw new ArgumentException("Actor path is empty", nameof(path));
            }

            var @interface = ActorInterface.Of(path.Type);
            var proxy      = @interface.Proxy(path.Id, GrainFactory);

            return(new ActorRef(path, proxy, invoker));
        }
 void addActorToList(ActorInterface actor)
 {
     currentActors++;
     for (int i = 0; i < spawnedActors.Count; i++)
     {
         if (spawnedActors[i] == null)
         {
             spawnedActors[i] = actor;
             return;
         }
     }
     spawnedActors.Add(actor);
 }
    public void spawnEnemy()
    {
        float   distance         = Random.Range(0, spawnRadius);
        float   angle            = Random.Range(0, 2 * Mathf.PI);
        Vector3 positionModifier = new Vector3(
            distance * Mathf.Sin(angle),
            distance * Mathf.Cos(angle),
            0);
        ActorInterface newActor = actorPoolController.createActor(
            transform.position + positionModifier);

        if (newActor != null)
        {
            addActorToList(newActor);
        }
    }
        private void Destruct()
        {
            if (m_actorInterface != null)
            {
                m_actorInterface.Delete();
                m_actorInterface = null;
            }

            if (m_assetInterface != null)
            {
                m_assetInterface.Delete();
                m_assetInterface = null;
            }

            if (m_renderMethodInterface != null)
            {
                m_renderMethodInterface.Delete();
                m_renderMethodInterface = null;
            }

            HvrScene.Remove(this);
        }
Exemple #13
0
        /// <summary>
        /// Connects this instance of client actor system to cluster
        /// </summary>
        /// <param name="retries">Number of retries in case on failure</param>
        /// <param name="retryTimeout">Timeout between retries. Default is 5 seconds</param>
        /// <exception cref="ArgumentOutOfRangeException">if <paramref name="retries"/> argument value is less than 0</exception>
        public void Connect(int retries = 0, TimeSpan?retryTimeout = null)
        {
            if (retryTimeout == null)
            {
                retryTimeout = TimeSpan.FromSeconds(5);
            }

            if (retries < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(retries),
                                                      "retries should be greater than or equal to 0");
            }

            while (!Connected && retries-- >= 0)
            {
                try
                {
                    GrainClient.Initialize(configuration);
                }
                catch (Exception ex)
                {
                    if (retries >= 0)
                    {
                        Trace.TraceWarning($"Can't connect to cluster. Trying again in {(int)retryTimeout.Value.TotalSeconds} seconds ... Got error: /n{ex}");
                        Thread.Sleep(retryTimeout.Value);
                    }
                    else
                    {
                        Trace.TraceError($"Can't connect to cluster. Max retries reached. Got error: /n{ex}");
                        throw;
                    }
                }
            }

            ActorInterface.Bind(GrainClient.GrainFactory);
        }
Exemple #14
0
 ActorRef(ActorPath path, IActorEndpoint endpoint)
     : this(path)
 {
     this.endpoint = endpoint;
     @interface    = ActorInterface.Of(path);
 }
 void RegisterActorInterfaces() => ActorInterface.Register(registry.Assemblies, registry.Mappings);
 void RegisterInterfaces() => ActorInterface.Register(assemblies, interfaces);
Exemple #17
0
 public static ActorRef Deserialize(ActorPath path) => new ActorRef(path, ActorInterface.Registered(path.Type));
Exemple #18
0
 ActorRef(ActorPath path, ActorInterface @interface)
     : this(path)
 {
     endpoint = @interface.Proxy(path);
 }
        private void Init()
        {
#if UNITY_EDITOR
            // In the case that this component is a prefab,
            // don't allow interface objects to be created
            if (PrefabUtility.GetPrefabType(this) == PrefabType.Prefab)
            {
                return;
            }

            // There are issues with releasing unmanaged memory while running in batch mode for OSX and iOS
            // TODO: Remove this check
            if (UnityEditorInternal.InternalEditorUtility.inBatchMode)
            {
                return;
            }
#endif

            m_actorInterface = new ActorInterface();
            m_actorInterface.Create();

            if (m_renderMethodInterface == null)
            {
                if (string.IsNullOrEmpty(m_renderMethodType))
                {
                    m_renderMethodType = HvrPlayerInterface.RenderMethod_GetDefaultMethodType();
                }

                // Create this HvrActor's rendermethod
                // !! Always create the rendermethod before creating the asset as
                // !! there is a work around in SetRenderMethodInterface which requires
                // !! the asset to be recreated if the rendermethod changes
                CreateRenderMethod(m_renderMethodType);
            }

            if (m_assetInterface == null)
            {
                // Create the asset
                if (string.IsNullOrEmpty(data) == false)
                {
                    CreateAsset(data, dataMode);
                }
            }

            if (m_assetInterface != null)
            {
                m_assetInterface.Seek(assetSeekTime);

                m_assetInterface.SetLooping(assetLoop);

                // Only allow assets to be played or seek when the application is playing
                if (Application.isPlaying)
                {
                    if (assetPlay)
                    {
                        m_assetInterface.Play();
                    }
                }
            }

#if UNITY_EDITOR
            // Handle case where HvrActor is duplicated within the Unity Editor
            // We need to ensure that the HvrActor has a unique material
            if (m_instanceID == 0)
            {
                m_instanceID = GetInstanceID();
            }
            else
            if (m_instanceID != GetInstanceID() && GetInstanceID() < 0)
            {
                m_instanceID = GetInstanceID();

                if (m_material != null)
                {
                    Material mat = new Material(m_material.shader);
                    mat.name = m_material.name;
                    mat.CopyPropertiesFromMaterial(m_material);
                    mat.shaderKeywords = m_material.shaderKeywords;
                    m_material         = mat;
                }
            }
#endif

            m_renderMesh = new Mesh();

            m_subroutineStack = new HvrActorShaderSubroutineStack();

            HvrScene.Add(this);
        }