示例#1
0
        public ClientConnectionHolder(IGameObjectObserver client, Guid clientId, IGameObjectSelfAccessor parent)
        {
            _working      = true;
            _client       = client;
            _parent       = parent;
            _messageQueue = new Queue <JediumBehaviourMessage[]>();
            _clientId     = clientId;

            _client.GotAddress();
            // Self.Tell(new ResendMessage(),null);
            Context.System.Scheduler.ScheduleTellRepeatedly(TimeSpan.FromSeconds(0), TimeSpan.FromMilliseconds(MainSettings.TickDelay), Self, _tick, ActorRefs.NoSender);
        }
示例#2
0
        //Мы предполагаем, что компонент Transform есть всегда
        public JediumGameObject(IGameObjectSelfAccessor actor, List <JediumBehaviourSnapshot> behaviours,
                                Dictionary <string, JediumBehaviourDBSnapshot> db_snaps,
                                Guid ownerId, Guid localId)
        {
            Actor       = actor;
            OwnerId     = ownerId;
            LocalId     = localId;
            _behaviours = new Dictionary <int, JediumBehaviour>();


            foreach (var new_beh in db_snaps)
            {
                JediumBehaviour toAdd = null;


                if (BehaviourTypeRegistry.BehaviourTypes.ContainsKey(new_beh.Key))
                {
                    Type behType = BehaviourTypeRegistry.BehaviourTypes[new_beh.Key];


                    if (behType != null)
                    {
                        JediumBehaviour plugin_beh =
                            (JediumBehaviour)Activator.CreateInstance(behType, this);
                        plugin_beh.FromDBSnapshot(new_beh.Value);
                        toAdd = plugin_beh;
                    }
                }


                if (toAdd != null)
                {
                    _behaviours.Add(TYPEBEHAVIOUR.GetTypeIndex(new_beh.Key), toAdd);
                }
            }


            //OLD DB
            if (behaviours != null)
            {
                foreach (var beh in behaviours)
                {
                    if (BehaviourTypeRegistry.BehaviourTypes.ContainsKey(beh.GetBehaviourType()))
                    {
                        //loaded behaviour
                        string bname = beh.GetBehaviourType();

                        Type behType = BehaviourTypeRegistry.BehaviourTypes[bname];

                        if (behType != null)
                        {
                            JediumBehaviour plugin_beh =
                                (JediumBehaviour)Activator.CreateInstance(behType, this);
                            plugin_beh.FromSnapshot(beh);
                            _behaviours.Add(TYPEBEHAVIOUR.GetTypeIndex(bname), plugin_beh);
                        }
                    }
                }
            }

            //special - transform

            if (!_behaviours.ContainsKey(TYPEBEHAVIOUR.GetTypeIndex("Transform")))
            {
                _behaviours.Add(TYPEBEHAVIOUR.GetTypeIndex("Transform"),
                                new JediumTransform(this, JediumTransformSnapshot.Identity));
            }
        }