public static GameObject Create(Vector3 pos) { var obj = new GameObject(); SpawnBlockEntity block = obj.AddComponent <SpawnBlockEntity>(); block.transform.position = pos; return(block.gameObject); }
Task IHandle <SpawnBlockEntity> .Handle(SpawnBlockEntity message) { AttachedObject.GetComponent <WorldComponent>().SetWorld(message.World); AttachedObject.GetComponent <BlockWorldPositionComponent>().SetBlockWorldPosition(message.Position); AttachedObject.QueueOperation(async() => { await AttachedObject.Tell(Enable.Default); if (AttachedObject.ValueStorage.IsDirty) { await AttachedObject.WriteStateAsync(); } }); return(Task.CompletedTask); }
void OnEntityBuilt(Planner planner, GameObject gameobject) { if (planner == null || gameobject == null) { return; } var player = planner.GetOwnerPlayer(); BaseEntity entity = gameobject.ToBaseEntity(); if (entity == null) { return; } if (SpawnBlockEntity.IsBlock(entity)) { player.ChatMessage("Строительство запрещено!!!\nВы находитесь в зоне возрождения, двигайтесь к центру или к полюсам карты!"); entity.Kill(); } }
async Task IHandle <SpawnBlockEntity> .Handle(SpawnBlockEntity message) { State.IsCooking = (await AttachedObject.World.GetBlockState(GrainFactory, AttachedObject.Position)) .IsId(BlockId.BlastFurnace); MarkDirty(); }
bool InSpawnZone(BaseEntity entity) => SpawnBlockEntity.IsBlock(entity);
void CreateBlock(Vector3 position) { blocks.Add(SpawnBlockEntity.Create(position)); }
bool IsValidSpawn(Vector3 point) { return(spawns.All(spawn => !(Vector3.Distance(point, spawn) < spawnRadius)) && SpawnBlockEntity.CanPlaceSpawn(point)); }
async Task IHandle <SpawnBlockEntity> .Handle(SpawnBlockEntity message) { await AttachedObject.GetComponent <WorldComponent>().SetWorld(message.World); await AttachedObject.GetComponent <BlockWorldPositionComponent>().SetBlockWorldPosition(message.Position); }