protected virtual void OnEnable() { entityValue = CreateEntity(); AddComponentsFromGameObject(gameObject); if (!checkChildrenForComponents) { return; } AddComponentsFromChildren(); }
public EntityWorker(int maximumEntities) { _availableEntities = new Queue <IEcsEntity>(maximumEntities); _entitySignatures = new Dictionary <IEcsEntity, S>(maximumEntities); for (var index = 0; index < maximumEntities; ++index) { var newEntity = new EcsEntity(); _availableEntities.Enqueue(newEntity); _entitySignatures.Add(newEntity, new S()); } }
public static void AddRecipient(EcsEntity e) { if (!e.IsAlive()) { return; } var player = e.Get <Player>(); recipients.Add(player.Connection.ClientConnection); }
public static int RLGetMaxHealth(this EcsEntity entity) { int value = 0; var c = entity.Get <NPCDataSheetComponent>(); if (c != null) { value = c.Stats.MaxHealthPoint; } return(value); }
public void Init() { GameObject carObj = GameObject.FindWithTag("Player"); GameObject[] victObjs = GameObject.FindGameObjectsWithTag("Alive"); EcsEntity carEntity = _world.NewEntity(); carEntity.Get <TransformRef>().value = carObj.transform; ref PhysicalBody physicalBody = ref carEntity.Get <PhysicalBody>();
public void Get_ById_AnotherEntity() { var entity1 = new EcsEntity() .AddComponent(new TestComponent1()); _ecsStoreService.AddEntity(entity1); var actualEntity = _ecsStoreService.GetEntity(Guid.NewGuid()); Assert.AreEqual(null, actualEntity); }
public void Generate() { map = world.NewEntity(); FillParameters(map); map.Get <GenerateHeightMapEvent>() = new GenerateHeightMapEvent() { OnGPU = OnGPU, PrintTimers = PrintTimers }; }
public override void RemoveFromEntity(ref EcsEntity entity) { if (startValue != null) { value.Copy(startValue); value = startValue; } entity.Unset <T>(); connected = false; }
public void RemoveEntity() { var entity1 = new EcsEntity().AddComponent(new TestComponent1()); _ecsStoreService.AddEntity(entity1); Assert.AreEqual(1, _ecsStore.Entities.Count); _ecsStoreService.RemoveEntity(entity1); Assert.AreEqual(0, _ecsStore.Entities.Count); }
public void PreInitialize() { EcsEntity mainEntity = GunshotWound3.StatsContainerEntity; var settings = _ecsWorld.AddComponent <NotificationSettingsComponent>(mainEntity); settings.CombineToOne = true; _ecsWorld.CreateEntityWith(out NotificationComponent startNotification); startNotification.Message = $"Great thanks for using ~g~GunShot Wound ~r~3~s~ v.{VERSION} by SH42913"; startNotification.Delay = 20f; }
public void StartGame() { EcsWorld _world = Service <EcsWorld> .Get(); EcsEntity _startEvent = _world.NewEntity(); _startEvent.Get <ChangeGameStateEvent>().State = GameState.Play; Service <UI> .Get().GameScreen.Show(); Hide(); }
public void Get_ByOneInterface() { var entity = new EcsEntity().AddComponent(new TestComponent1()); _ecsStoreService.AddEntity(entity); var actualEntity = _ecsStoreService.GetEntities(typeof(TestComponent1)); Assert.AreEqual(1, actualEntity.Count); Assert.AreEqual(entity, actualEntity.FirstOrDefault()); }
public void Run() { foreach (int i in _newPeds) { Ped ped = _newPeds.Components1[i].ThisPed; EcsEntity pedEntity = _newPeds.Entities[i]; var armor = _ecsWorld.AddComponent <PedArmorComponent>(pedEntity); armor.Armor = ped.Armor; } }
public void Get_ById_ExistEntity() { var entity1 = new EcsEntity() .AddComponent(new TestComponent1()); _ecsStoreService.AddEntity(entity1); var actualEntity = _ecsStoreService.GetEntity(entity1.Id); Assert.AreEqual(entity1, actualEntity); }
public static void MarkAsUpdated <T>(this EcsEntity entity) where T : class, new() { #if DEBUG if (entity.Get <T>() == null) { throw new Exception($"Entity has no {typeof(T).Name} and can be marked as updated!"); } #endif entity.Set <Updated <T> >(); }
public void Run() { foreach (var i in filter) { EcsEntity entity = filter.GetEntity(i); if (validateEntity(entity)) { createSprite(entity); } } }
public void Add() { var entity = new EcsEntity().AddComponent(new TestComponent1()); _ecsStoreService.AddEntity(entity); var actualEntity = _ecsStore.Entities.FirstOrDefault(); Assert.AreEqual(_ecsStore.Entities.Count, 1); Assert.AreEqual(entity, actualEntity.Value); Assert.AreNotEqual(default(Guid), actualEntity.Value.Id); Assert.AreEqual(actualEntity.Value.Id, actualEntity.Key); }
protected override void ResetEffect(Ped ped, EcsEntity pedEntity) { bool isPlayer = EcsWorld.GetComponent <PlayerMarkComponent>(pedEntity) != null; if (!isPlayer) { return; } NativeFunction.Natives.STOP_GAMEPLAY_CAM_SHAKING(true); EcsWorld.RemoveComponent <PermanentCameraShakeComponent>(pedEntity, true); }
/// <summary> /// Process supplied <see cref="SelltowerRequest"/>. /// </summary> /// <param name="request">Request to process.</param> public void SellTower(SelltowerRequest request) { foreach (int i in this.towerFilter) { ref EcsEntity towerEntity = ref this.towerFilter.GetEntity(i); if (request.TowerId != (short)towerEntity.GetInternalId()) { continue; } // Perform changes ref GameComponent game = ref this.gameFilter.Get1(0);
private void LoadUiAssets() { resoursesEntity = world.NewEntityWith(out PlayerResourcesComponent playerAsset); playerAsset.Semki = 50; playerAsset.Cash = 1000; playerAsset.ResoursesUiDisplay = GameObject.Instantiate(Resources.Load <Canvas>(@"Prefabs/GUI/PlayerInfo")); var assets = resoursesEntity.Set <BuildingAssetsComponent>(); assets.InBuildingCanvasesAssets = GetInBuildingCanvasesAssets(); assets.BuildingsAssets = GetAllBuildingAssets(); }
public static string Name(this Ped ped, EcsEntity entity) { string name = ped.Exists() ? ped.Model.Name : "NOT_EXISTS"; #if DEBUG return($"{name}({entity})"); #else return($"{name}"); #endif }
private void createSpriteForItem(EcsEntity entity) { ItemComponent item = entity.Get <ItemComponent>(); ItemVisualComponent visual = new ItemVisualComponent(); Vector3 spritePosition = ViewUtil.fromModelToScene(entity.pos()); visual.go = Object.Instantiate(itemPrefab, spritePosition + new Vector3(0, 0, -0.1f), Quaternion.identity); visual.go.transform.SetParent(GameView.get().mapHolder); visual.spriteRenderer = visual.go.GetComponent <SpriteRenderer>(); visual.spriteRenderer.sprite = createSprite(ItemTypeMap.getItemType(item.type)); entity.Replace(visual); }
public void AttachToEntity(EcsEntity parentEntity) { #if DEBUG if (!entity.IsNull()) { throw new Exception($"{nameof(HybridEntity)} already attached to {nameof(EcsEntity)}"); } #endif entityValue = parentEntity; FillEntityWithComponents(); }
protected override void ResetEffect(Ped ped, EcsEntity pedEntity) { bool isPlayer = EcsWorld.GetComponent <PlayerMarkComponent>(pedEntity) != null; if (!isPlayer) { return; } NativeFunction.Natives.xB4EDDC19532BFB85(); EcsWorld.RemoveComponent <MainScreenEffectComponent>(pedEntity, true); }
public void Add(EcsEntity entity) { if (!entity.IsAlive()) { throw new Exception("Can't add entity to EntityList as it's not active."); } ResizeIfNeeded(); entities[count] = entity; count++; }
public void registerItem(EcsEntity item) { validateForPlacing(item); Vector3Int position = item.pos(); if (!itemsOnMap.ContainsKey(position)) { itemsOnMap.Add(position, new List <EcsEntity>()); } itemsOnMap[position].Add(item); all.Add(item); }
public override void AddToEntity(ref EcsEntity entity) { startValue = value; value = entity.Set <T>(); connected = true; if (startValue != null) { startValue.Copy(value); MarkAsUpdated(); } }
public override void EntityInit(EcsEntity ecsEntity, EcsWorld world, bool OnScene) { MarkerRoot mRoot = ecsEntity.Set <MarkerRoot>(); mRoot.FriendlyMarker = this._friendlyMarker; mRoot.EnemyMarker = this._enemyMarker; if (OnScene) { Destroy(this); } }
public override void EntityInit(EcsEntity ecsEntity, EcsWorld world, bool OnScene) { ExplosionRoot eRoot = ecsEntity.Set <ExplosionRoot>(); eRoot.Explosion = this._explosion; _explosion.Play(); if (OnScene) { Destroy(this); } }
public bool Contains(EcsEntity entity) { for (var i = 0; i < count; i++) { if (entities[i] == entity) { return(true); } } return(false); }