Exemplo n.º 1
0
 void Components_ComponentRemoved(Type t, MyEntityComponentBase c)
 {
     if (t == typeof(MyPhysicsComponentBase))
     {
         m_physics = null;
     }
     else if (t == typeof(MySyncComponentBase))
     {
         m_syncObject = null;
     }
     else if (t == typeof(MyGameLogicComponent))
     {
         m_gameLogic = null;
     }
     else if (t == typeof(MyPositionComponentBase))
     {
         m_position = null;
     }
     else if (t == typeof(MyHierarchyComponentBase))
     {
         m_hierarchy = null;
     }
     else if (t == typeof(MyRenderComponentBase))
     {
         m_render = null;
     }
 }
Exemplo n.º 2
0
 internal void SetTarget(MyEntityComponentBase owner)
 {
     _fixedEntry = ProfilerFixedEntry.Count;
     FreeHandles();
     _owner  = GCHandle.Alloc(owner, GCHandleType.Weak);
     _getter = GetterImplEntityComponent;
 }
Exemplo n.º 3
0
 void Components_ComponentRemoved(Type t, MyEntityComponentBase c)
 {
     if ((typeof(MyPhysicsComponentBase)).IsAssignableFrom(t))
     {
         m_physics = null;
     }
     else if ((typeof(MySyncComponentBase)).IsAssignableFrom(t))
     {
         m_syncObject = null;
     }
     else if ((typeof(MyGameLogicComponent)).IsAssignableFrom(t))
     {
         m_gameLogic = null;
     }
     else if ((typeof(MyPositionComponentBase)).IsAssignableFrom(t))
     {
         PositionComp = new MyNullPositionComponent();
     }
     else if ((typeof(MyHierarchyComponentBase)).IsAssignableFrom(t))
     {
         m_hierarchy = null;
     }
     else if ((typeof(MyRenderComponentBase)).IsAssignableFrom(t))
     {
         Render = new MyNullRenderComponent();
     }
 }
Exemplo n.º 4
0
 void Components_ComponentAdded(Type t, MyEntityComponentBase c)
 {
     if (t == typeof(MyPhysicsComponentBase))
     {
         m_physics = c as MyPhysicsBody;
     }
     else if (t == typeof(MySyncComponentBase))
     {
         m_syncObject = c as MySyncComponentBase;
     }
     else if (t == typeof(MyGameLogicComponent))
     {
         m_gameLogic = c as MyGameLogicComponent;
     }
     else if (t == typeof(MyPositionComponentBase))
     {
         m_position = c as MyPositionComponentBase;
     }
     else if (t == typeof(MyHierarchyComponentBase))
     {
         m_hierarchy = c as MyHierarchyComponentBase;
     }
     else if (t == typeof(MyRenderComponentBase))
     {
         m_render = c as MyRenderComponentBase;
     }
 }
 void OnNewComponentAdded(Type type, MyEntityComponentBase component)
 {
     if (component is MyInventory)
     {
         InitBlock();
     }
 }
Exemplo n.º 6
0
 void Components_ComponentAdded(Type t, MyEntityComponentBase c)
 {
     if ((typeof(MyPhysicsComponentBase)).IsAssignableFrom(t))
     {
         m_physics = c as MyPhysicsBody;
     }
     else if ((typeof(MySyncComponentBase)).IsAssignableFrom(t))
     {
         m_syncObject = c as MySyncComponentBase;
     }
     else if ((typeof(MyGameLogicComponent)).IsAssignableFrom(t))
     {
         m_gameLogic = c as MyGameLogicComponent;
     }
     else if ((typeof(MyPositionComponentBase)).IsAssignableFrom(t))
     {
         m_position = c as MyPositionComponentBase;
         if (m_position == null)
         {
             PositionComp = new MyNullPositionComponent();
         }
     }
     else if ((typeof(MyHierarchyComponentBase)).IsAssignableFrom(t))
     {
         m_hierarchy = c as MyHierarchyComponentBase;
     }
     else if ((typeof(MyRenderComponentBase)).IsAssignableFrom(t))
     {
         m_render = c as MyRenderComponentBase;
         if (m_render == null)
         {
             Render = new MyNullRenderComponent();
         }
     }
 }
Exemplo n.º 7
0
 private void OnNewComponentAdded(System.Type type, MyEntityComponentBase component)
 {
     if (component is MyInventory)
     {
         this.InitBlock();
     }
 }
Exemplo n.º 8
0
 internal static FatProfilerEntry EntityComponentEntry(MyEntityComponentBase component)
 {
     if (!ProfileEntityComponentsUpdate || component == null || component is MyCompositeGameLogicComponent)
     {
         return(null);
     }
     return(EntityEntry(component.Entity)?.GetFat(_componentsKey)?.GetFat(component));
 }
Exemplo n.º 9
0
 private void OnInventoryAggregateRemoved(MyEntityComponentBase component)
 {
     this.m_inputInventory  = null;
     this.m_outputInventory = null;
     this.m_inventoryAggregate.BeforeRemovedFromContainer -= new Action <MyEntityComponentBase>(this.OnInventoryAggregateRemoved);
     this.m_inventoryAggregate.OnAfterComponentAdd        -= new Action <MyInventoryAggregate, MyInventoryBase>(this.OnInventoryAddedToAggregate);
     this.m_inventoryAggregate.OnBeforeComponentRemove    -= new Action <MyInventoryAggregate, MyInventoryBase>(this.OnBeforeInventoryRemovedFromAggregate);
     this.m_inventoryAggregate = null;
 }
Exemplo n.º 10
0
 private void OnInventoryAggregateRemoved(MyEntityComponentBase component)
 {
     m_inputInventory  = null;
     m_outputInventory = null;
     m_inventoryAggregate.BeforeRemovedFromContainer -= OnInventoryAggregateRemoved;
     m_inventoryAggregate.OnAfterComponentAdd        -= OnInventoryAddedToAggregate;
     m_inventoryAggregate.OnBeforeComponentRemove    -= OnBeforeInventoryRemovedFromAggregate;
     m_inventoryAggregate = null;
 }
Exemplo n.º 11
0
 private void OnComponentRemoved(Type type, MyEntityComponentBase ec)
 {
     if (ec == Value)
     {
         var old = _value;
         _value = null;
         ValueChanged?.Invoke(old, _value);
     }
 }
Exemplo n.º 12
0
        public void Init(MyEnvironmentSector sector, List <int> items)
        {
            m_sector = sector;
            MyEntityComponentBase comp = (MyEntityComponentBase)m_sector.Owner;

            m_planet = comp.Entity as MyPlanet;
            m_items  = items;

            LoadVoxelMapsInfo();
        }
Exemplo n.º 13
0
        private void OnComponentAdded(Type type, MyEntityComponentBase ec)
        {
            var value = (ec as T) ?? (ec as MyCompositeGameLogicComponent)?.GetAs <T>();

            if (value != null)
            {
                var old = _value;
                _value = value;
                ValueChanged?.Invoke(old, _value);
            }
        }
Exemplo n.º 14
0
        private void OnComponentAdded(Type type, MyEntityComponentBase cmp)
        {
            var inv = cmp as IMyInventory;

            if (inv == null)
            {
                return;
            }
            if (_listeningInventories.ContainsKey(inv))
            {
                return;
            }
            _listeningInventories.Add(inv, _listeningInventoriesOrder.Count);
            _listeningInventoriesOrder.Add(inv);
        }
 void container_ComponentRemoved(Type type, MyEntityComponentBase comp)
 {
     if (type == typeof(MySyncComponentBase))
     {
         m_syncObject = null;
     }
     else if (type == typeof(MyPhysicsComponentBase))
     {
         m_physics = null;
     }
     else if (type == typeof(MyHierarchyComponentBase))
     {
         m_hierarchy = null;
     }
 }
 void container_ComponentAdded(Type type, MyEntityComponentBase comp)
 {
     if (type == typeof(MySyncComponentBase))
     {
         m_syncObject = comp as MySyncComponentBase;
     }
     else if (type == typeof(MyPhysicsComponentBase))
     {
         m_physics = comp as MyPhysicsComponentBase;
     }
     else if (type == typeof(MyHierarchyComponentBase))
     {
         m_hierarchy = comp as MyHierarchyComponentBase;
     }
 }
Exemplo n.º 17
0
        private void OnComponentAdded(Type type, MyEntityComponentBase component)
        {
            MyInventoryAggregate aggregate = component as MyInventoryAggregate;

            if (aggregate != null)
            {
                this.m_inventoryAggregate = aggregate;
                this.m_inventoryAggregate.BeforeRemovedFromContainer += new Action <MyEntityComponentBase>(this.OnInventoryAggregateRemoved);
                this.m_inventoryAggregate.OnAfterComponentAdd        += new Action <MyInventoryAggregate, MyInventoryBase>(this.OnInventoryAddedToAggregate);
                this.m_inventoryAggregate.OnBeforeComponentRemove    += new Action <MyInventoryAggregate, MyInventoryBase>(this.OnBeforeInventoryRemovedFromAggregate);
                foreach (MyInventory inventory in this.m_inventoryAggregate.ChildList.Reader)
                {
                    this.OnInventoryAddedToAggregate(aggregate, inventory);
                }
            }
        }
Exemplo n.º 18
0
        private void OnComponentRemoved(Type type, MyEntityComponentBase cmp)
        {
            var inv = cmp as IMyInventory;

            if (inv == null)
            {
                return;
            }
            int index;

            if (!_listeningInventories.TryGetValue(inv, out index))
            {
                return;
            }
            _listeningInventories.Remove(inv);
            _listeningInventoriesOrder.RemoveAtFast(index);
        }
Exemplo n.º 19
0
        void OnRemovedFromContainer(MyEntityComponentBase obj)
        {
            InventoryReplicableUpdate.Reset(itemsGroup);
            InventoryReplicableUpdate.Reset(propsGroup);
            if (Instance?.Owner is MyCubeBlock block)
            {
                block.SlimBlock.CubeGridChanged -= OnBlockCubeGridChanged;
                if (block is MyTerminalBlock tb)
                {
                    tb.OwnershipChanged -= OnOwnershipChanged;
                    InventoryReplicableUpdate.ResetChangedOwnership(itemsGroup);
                    InventoryReplicableUpdate.ResetChangedOwnership(propsGroup);
                }
            }

            RaiseDestroyed();
        }
Exemplo n.º 20
0
        private static void EntityComponentEntry(MyEntityComponentBase component, ref MultiProfilerEntry mpe)
        {
            if (_activeProfilers == 0)
            {
                return;
            }

            if (component.Entity != null)
            {
                EntityEntry(component.Entity, ref mpe);
            }

            // ReSharper disable once InvertIf
            if (_activeProfilersByType[(int)ProfilerRequestType.Mod] > 0)
            {
                var modContext = ModLookupUtils.GetMod(component.GetType()) ?? MyModContext.BaseGame;
                mpe.Add(PerfMod.GetOrAdd(modContext, DelMakeMod));
            }
        }
Exemplo n.º 21
0
 private static SlimProfilerEntry SingleMethodEntryProvider_EntityComponent(MyEntityComponentBase __instance, string __key)
 {
     return(ProfilerData.EntityComponentEntry(__instance)?.GetSlim(__key));
 }
Exemplo n.º 22
0
 private void OnComponentRemoved(Type type, MyEntityComponentBase c)
 {
     (c as MyGameLogicComponent)?.GetAs <ProductionBlueprintProhibitor>()?.SetController(null);
 }
Exemplo n.º 23
0
 public ComponentDependency(MyEntityComponentBase owner)
 {
     _owner = owner;
 }