public IEnumerator TimedEffect(Vector3Int position, float time, bool isEmp, TileChangeManager tileChangeManager) { string effectName; OverlayType effectOverlayType; if (isEmp) { effectName = "EMPEffect"; effectOverlayType = OverlayType.EMP; } else { effectName = "Fire"; effectOverlayType = OverlayType.Fire; } //Dont add effect if it is already there if (tileChangeManager.MetaTileMap.HasOverlay(position, TileType.Effects, effectName)) { yield break; } tileChangeManager.MetaTileMap.AddOverlay(position, TileType.Effects, effectName); yield return(WaitFor.Seconds(time)); tileChangeManager.MetaTileMap.RemoveOverlaysOfType(position, LayerType.Effects, effectOverlayType); }
private void Awake() { tileChangeManager = GetComponentInParent <TileChangeManager>(); metaDataLayer = GetComponent <MetaDataLayer>(); hotspots = new Dictionary <Vector3Int, MetaDataNode>(); }
public IEnumerator KineticAnim() { Transform cellTransform = rigidBody.gameObject.transform; MetaTileMap layerMetaTile = cellTransform.GetComponentInParent <MetaTileMap>(); var position = layerMetaTile.WorldToCell(Vector3Int.RoundToInt(rigidBody.gameObject.AssumedWorldPosServer())); TileChangeManager tileChangeManager = transform.GetComponentInParent <TileChangeManager>(); // Store the old effect LayerTile oldEffectLayerTile = tileChangeManager.GetLayerTile(position, LayerType.Effects); tileChangeManager.UpdateTile(position, TileType.Effects, "KineticAnimation"); yield return(WaitFor.Seconds(.4f)); tileChangeManager.RemoveTile(position, LayerType.Effects); // Restore the old effect if any (ex: cracked glass, does not work) if (oldEffectLayerTile) { tileChangeManager.UpdateTile(position, oldEffectLayerTile); } isOnDespawn = false; global::Despawn.ClientSingle(gameObject); }
void Awake() { tileChangeManager = transform.GetComponentInParent <TileChangeManager>(); metaDataLayer = transform.GetComponentInParent <MetaDataLayer>(); metaTileMap = transform.GetComponentInParent <MetaTileMap>(); Layer = GetComponent <Layer>(); matrix = GetComponentInParent <Matrix>(); tileChangeManager.OnFloorOrPlatingRemoved.RemoveAllListeners(); tileChangeManager.OnFloorOrPlatingRemoved.AddListener(cellPos => { //Poke items when both floor and plating are gone //As they might want to change matrix if (!metaTileMap.HasTile(cellPos, LayerType.Floors, true) && !metaTileMap.HasTile(cellPos, LayerType.Base, true) && metaTileMap.HasTile(cellPos, LayerType.Objects, true) ) { foreach (var customNetTransform in matrix.Get <CustomNetTransform>(cellPos, true)) { customNetTransform.CheckMatrixSwitch(); } } }); }
public IEnumerator KineticAnim(Collision2D coll) { Transform cellTransform = rigidBody.gameObject.transform; MetaTileMap layerMetaTile = cellTransform.GetComponentInParent <MetaTileMap>(); ContactPoint2D firstContact = coll.GetContact(0); Vector3 hitPos = firstContact.point; Vector3 forceDir = Direction; forceDir.z = 0; Vector3 bulletHitTarget = hitPos + (forceDir * 0.2f); Vector3Int cellPos = layerMetaTile.WorldToCell(Vector3Int.RoundToInt(bulletHitTarget)); TileChangeManager tileChangeManager = transform.GetComponentInParent <TileChangeManager>(); // Store the old effect LayerTile oldEffectLayerTile = tileChangeManager.GetLayerTile(cellPos, LayerType.Effects); tileChangeManager.UpdateTile(cellPos, TileType.Effects, "KineticAnimation"); yield return(WaitFor.Seconds(.4f)); tileChangeManager.RemoveTile(cellPos, LayerType.Effects); // Restore the old effect if any (ex: cracked glass, does not work) if (oldEffectLayerTile) { tileChangeManager.UpdateTile(cellPos, oldEffectLayerTile); } isOnDespawn = false; global::Despawn.ClientSingle(gameObject); }
[Command] //Remember with the parent you can only send networked objects: public void CmdPlaceItem(EquipSlot equipSlot, Vector3 pos, GameObject newParent, bool isTileMap) { if (playerScript.canNotInteract() || !playerScript.IsInReach(pos, true)) { return; } var inventorySlot = Inventory[equipSlot]; GameObject item = inventorySlot.Item; if (item != null && newParent != null) { InventoryManager.DropItem(inventorySlot.Item, pos, this); if (isTileMap) { TileChangeManager tileChangeManager = newParent.GetComponentInParent <TileChangeManager>(); //item.transform.parent = tileChangeManager.ObjectParent.transform; TODO } else { item.transform.parent = newParent.transform; } // TODO //ReorderGameobjectsOnTile(pos); } }
private void EnsureInit() { if (registerTile != null) { return; } if (!isWindowedDoor) { closedLayer = LayerMask.NameToLayer("Door Closed"); } else { closedLayer = LayerMask.NameToLayer("Windows"); } spriteRenderer = GetComponentInChildren <SpriteRenderer>(); closedSortingLayer = SortingLayer.NameToID("Doors Closed"); openSortingLayer = SortingLayer.NameToID("Doors Open"); openLayer = LayerMask.NameToLayer("Door Open"); registerTile = gameObject.GetComponent <RegisterDoor>(); tileChangeManager = GetComponentInParent <TileChangeManager>(); hackingProcess = GetComponent <HackingProcessBase>(); isHackable = hackingProcess != null; hackingLoaded = false; }
[Command] //Remember with the parent you can only send networked objects: public void CmdPlaceItem(string slotName, Vector3 pos, GameObject newParent, bool isTileMap) { if (playerScript.canNotInteract() || !playerScript.IsInReach(pos)) { return; } if (!SlotNotEmpty(slotName)) { return; } GameObject item = Inventory[slotName].Item; InventoryManager.DropGameItem(gameObject, Inventory[slotName].Item, pos); ClearInventorySlot(slotName); if (item != null && newParent != null) { if (isTileMap) { TileChangeManager tileChangeManager = newParent.GetComponentInParent <TileChangeManager>(); // item.transform.parent = tileChangeManager.ObjectParent.transform; TODO } else { item.transform.parent = newParent.transform; } // TODO // ReorderGameobjectsOnTile(pos); } }
public IEnumerator SpawnLavaLandCo() { foreach (var script in randomGenScripts) { if (script == null) { continue; } script.numR = Random.Range(1, 7); script.DoSim(); } tileChangeManager = MatrixManager.Instance.lavaLandMatrix.transform.parent.GetComponent <TileChangeManager>(); GenerateStructures(); MatrixManager.Instance.lavaLandMatrix.transform.parent.GetComponent <OreGenerator>().RunOreGenerator(); SetQuantumPads(); Logger.Log("Finished generating LavaLand", Category.Round); yield break; }
private void Start() { tileChangeManager = GetComponentInParent <TileChangeManager>(); registerObject = GetComponent <RegisterObject>(); GetComponent <Integrity>().OnWillDestroyServer.AddListener(OnWillDestroyServer); objectBehaviour = GetComponent <ObjectBehaviour>(); }
public IEnumerator TimedEffect(Vector3Int position, float time, TileChangeManager tileChangeManager) { tileChangeManager.UpdateTile(position, TileType.Effects, "Fire"); yield return(WaitFor.Seconds(time)); tileChangeManager.RemoveTile(position, LayerType.Effects); }
//Script does not work on asteroids but mines AsteroidStation ore public void BulletHitInteract(Collision2D coll, Vector2 Direction) { Transform cellTransform = coll.transform; MetaTileMap layerMetaTile = cellTransform.GetComponentInParent <MetaTileMap>(); TileChangeManager tileChangeManager = cellTransform.GetComponentInParent <TileChangeManager>(); ContactPoint2D firstContact = coll.GetContact(0); Vector3 hitPos = firstContact.point; Vector3 forceDir = Direction; forceDir.z = 0; Vector3 bulletHitTarget = hitPos + (forceDir * 0.2f); Vector3Int cellPos = layerMetaTile.WorldToCell(Vector3Int.RoundToInt(bulletHitTarget)); LayerTile getTile = layerMetaTile.GetTile(cellPos, LayerType.Walls); if (getTile != null) { if (Validations.IsMineableAt(bulletHitTarget, layerMetaTile)) { SoundManager.PlayNetworkedAtPos("BreakStone", bulletHitTarget); var tile = getTile as BasicTile; Spawn.ServerPrefab(tile.SpawnOnDeconstruct, bulletHitTarget, count: tile.SpawnAmountOnDeconstruct); tileChangeManager.RemoveTile(cellPos, LayerType.Walls); tileChangeManager.RemoveTile(cellPos, LayerType.Effects); } return; } }
private void Start() { LavaLandManager.Instance.randomGenScripts.Add(this); tileChangeManager = transform.parent.parent.parent.GetComponent <TileChangeManager>(); }
private void Awake() { initialOffset = Vector3Int.CeilToInt(gameObject.transform.position); reactionManager = GetComponent <ReactionManager>(); metaDataLayer = GetComponent <MetaDataLayer>(); MatrixMove = GetComponentInParent <MatrixMove>(); tileChangeManager = GetComponentInParent <TileChangeManager>(); OnEarthquake.AddListener((worldPos, magnitude) => { var cellPos = metaTileMap.WorldToCell(worldPos); var bounds = new BoundsInt(cellPos - new Vector3Int(magnitude, magnitude, 0), new Vector3Int(magnitude * 2, magnitude * 2, 1)); foreach (var pos in bounds.allPositionsWithin) { foreach (var player in Get <PlayerScript>(pos, true)) { if (player.IsGhost) { continue; } player.registerTile.ServerSlip(true); } //maybe shake items somehow, too } }); }
void Awake() { tileChangeManager = transform.root.GetComponent <TileChangeManager>(); tileTrigger = transform.root.GetComponent <TileTrigger>(); metaDataLayer = transform.parent.GetComponent <MetaDataLayer>(); metaTileMap = transform.parent.GetComponent <MetaTileMap>(); Layer = GetComponent <Layer>(); }
public override IEnumerator Process() { yield return(WaitFor(ManagerSubject)); TileChangeManager tm = NetworkObject.GetComponent <TileChangeManager>(); tm.InitServerSync(data); }
private void DoWallDeconstruction(Vector3Int cellPos, TileChangeManager tcm, Vector3 worldPos) { tcm.RemoveTile(cellPos, LayerType.Walls); SoundManager.PlayNetworkedAtPos("Deconstruct", worldPos, 1f); PoolManager.PoolNetworkInstantiate(metalPrefab, worldPos, tcm.transform); PoolManager.PoolNetworkInstantiate(wallGirderPrefab, worldPos, tcm.transform); }
private void Start() { metaTileMap = GetComponentInChildren <MetaTileMap>(); matrix = GetComponentInChildren <Matrix>(); objectLayer = GetComponentInChildren <ObjectLayer>(); tileChangeManager = GetComponent <TileChangeManager>(); CacheTileMaps(); }
private void Start() { OBSTACLE_MASK = LayerMask.GetMask("Walls", "Door Closed"); registerItem = GetComponent <RegisterItem>(); objectBehaviour = GetComponent <ObjectBehaviour>(); tileChangeManager = GetComponentInParent <TileChangeManager>(); }
void Awake() { tileChangeManager = transform.GetComponentInParent <TileChangeManager>(); metaDataLayer = transform.GetComponentInParent <MetaDataLayer>(); metaTileMap = transform.GetComponentInParent <MetaTileMap>(); Layer = GetComponent <Layer>(); }
private void Start() { DAMAGEABLE_MASK = LayerMask.GetMask("Players", "Machines", "Default" /*, "Lighting", "Items"*/); OBSTACLE_MASK = LayerMask.GetMask("Walls", "Door Closed"); registerObject = GetComponent <RegisterObject>(); objectBehaviour = GetComponent <ObjectBehaviour>(); tileChangeManager = GetComponentInParent <TileChangeManager>(); }
private void Awake() { tileChangeManager = GetComponentInParent <TileChangeManager>(); metaDataLayer = GetComponent <MetaDataLayer>(); matrix = GetComponent <Matrix>(); hotspots = new Dictionary <Vector3Int, MetaDataNode>(); winds = new UniqueQueue <MetaDataNode>(); tilemapDamages = GetComponentsInChildren <TilemapDamage>(); }
//Create a constructor for each new use type of FinishProgressAction (i.e you might add an Action type called HandCuff) public FinishProgressAction(Action action, TileChangeManager _tileChangeManager, TileType _tileType, Vector3 _cellPos, Vector3 _worldPos, GameObject _originator) { actionType = action; tileChangeManager = _tileChangeManager; tileType = _tileType; cellPos = _cellPos; worldPos = _worldPos; originator = _originator; }
private void Start() { OBSTACLE_MASK = LayerMask.GetMask("Walls", "Door Closed"); registerItem = GetComponent <RegisterItem>(); objectBehaviour = GetComponent <ObjectBehaviour>(); tileChangeManager = GetComponentInParent <TileChangeManager>(); // Set grenade to locked state by default UpdateSprite(LOCKED_SPRITE); }
IEnumerator WaitForMapToLoad(string data, uint managerId) { while (!NetworkIdentity.spawned.ContainsKey(managerId)) { yield return(WaitFor.EndOfFrame); } TileChangeManager tm = NetworkIdentity.spawned[managerId].GetComponent <TileChangeManager>(); tm.InitServerSync(data); }
public override void Process() { //server doesn't need this message, it messes with its own tiles. if (CustomNetworkManager.IsServer) { return; } LoadNetworkObject(ManagerSubject); TileChangeManager tm = NetworkObject.GetComponent <TileChangeManager>(); tm.InitServerSync(data); }
//Server only: public void TryTileDeconstruct(TileChangeManager tileChangeManager, TileType tileType, Vector3 cellPos, Vector3 worldPos) { var cellPosInt = Vector3Int.RoundToInt(cellPos); switch (tileType) { case TileType.Wall: DoWallDeconstruction(cellPosInt, tileChangeManager, worldPos); tileChangeManager.gameObject.GetComponent <SubsystemManager>().UpdateAt(cellPosInt); break; } }
private void Start() { metaTileMap = GetComponentInChildren <MetaTileMap>(); matrix = GetComponentInChildren <Matrix>(); objectLayer = GetComponentInChildren <ObjectLayer>(); tileChangeManager = GetComponent <TileChangeManager>(); CacheTileMaps(); // register message handler for CableCuttingMessage here because CableCuttingWindow prefab won't be loaded on server // so registration cannot be inside Start or Awake method inside CableCuttingWindow NetworkServer.RegisterHandler <CableCuttingWindow.CableCuttingMessage>(ServerPerformCableCuttingInteraction); }
// Start is called before the first frame update void Start() { var metaTileMap = GetComponentInChildren <MetaTileMap>(); wallTilemap = metaTileMap.Layers[LayerType.Walls].GetComponent <Tilemap>(); tileChangeManager = GetComponent <TileChangeManager>(); if (CustomNetworkManager.IsServer) { List <OreProbability> weightedList = new List <OreProbability>(); foreach (var ores in config.OreProbabilities) { for (int i = 0; i < ores.SpawnChance; i++) { weightedList.Add(ores); } } BoundsInt bounds = wallTilemap.cellBounds; List <Vector3Int> miningTiles = new List <Vector3Int>(); for (int n = bounds.xMin; n < bounds.xMax; n++) { for (int p = bounds.yMin; p < bounds.yMax; p++) { Vector3Int localPlace = (new Vector3Int(n, p, 0)); if (wallTilemap.HasTile(localPlace)) { var tile = wallTilemap.GetTile(localPlace); if (tile.name.Contains("rock_wall")) { miningTiles.Add(localPlace); } } } } int numberOfTiles = (int)((miningTiles.Count / 100f) * config.Density); for (int i = 0; i < numberOfTiles; i++) { var oreTile = miningTiles[RANDOM.Next(miningTiles.Count)]; var oreCategory = weightedList[RANDOM.Next(weightedList.Count)]; tileChangeManager.UpdateTile(oreTile, oreCategory.WallTile); var intLocation = oreTile + Vector3Int.zero; intLocation.z = -1; tileChangeManager.UpdateTile(intLocation, oreCategory.OverlayTile); NodeScatter(oreTile, oreCategory); } } }
public IEnumerator TimedFireEffect(Vector3Int position, float time, TileChangeManager tileChangeManager) { //Dont do fire if already fire if (tileChangeManager.MetaTileMap.HasOverlay(position, TileType.Effects, "Fire")) { yield break; } tileChangeManager.MetaTileMap.AddOverlay(position, TileType.Effects, "Fire"); yield return(WaitFor.Seconds(time)); tileChangeManager.MetaTileMap.RemoveOverlaysOfType(position, LayerType.Effects, OverlayType.Fire); }