示例#1
0
        public void SendSetEntityFaction(MyEntity entity, MyMwcObjectBuilder_FactionEnum faction)
        {
            Debug.Assert(entity.EntityId.HasValue, "Entity must have id");

            var msg = new MyEventSetEntityFaction();

            msg.Faction  = faction;
            msg.EntityId = entity.EntityId.Value.NumericValue;

            Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableOrdered);
        }
示例#2
0
        void OnSetEntityFaction(ref MyEventSetEntityFaction msg)
        {
            MyEntity entity;

            if (MyEntities.TryGetEntityById(msg.EntityId.ToEntityId(), out entity))
            {
                entity.Faction = msg.Faction;
            }
            else
            {
                Alert("Entity not found: " + msg.EntityId, msg.SenderEndpoint, msg.EventType);
            }
        }