Exemple #1
0
        public void DestroyActor(ActorPath path)
        {
            // TODO: handle destroying remote actor

            lock (ActorLock)
            {
                var container = GetActor(path);

                if (container is null)
                {
                    Log.Warning($"Tried to destroy {path} but it is not in the system");
                    return;
                }

                Log.Info($"Destroying actor {path}");

                container.Status = ActorStatus.Destroying;

                container.Actor.CallOnDestruction();

                container.Actor.DestroyHandlerStack();

                if (Actors.ContainsKey(container.Actor.InternalParent.Path))
                {
                    // remove self from parent
                    var parent          = Actors[container.Actor.InternalParent.Path];
                    var child_to_remove = parent.Actor.InternalChildren.Find(x => x.Path == path);
                    if (child_to_remove is { })
Exemple #2
0
        public void AddActor(Actor.GActor actor)
        {
            if (Actors.ContainsKey(actor.ActorId))
            {
                return;
            }
            mActorsDictionaryDirty = true;
            Actors[actor.ActorId]  = actor;
            actor.OnAddToWorld(this);

            for (int i = 0; i < actor.Children.Count; ++i)
            {
                AddActor(actor.Children[i]);
            }
            OnAddActor?.Invoke(actor);
        }