public static void TransportObject(PushPull pushPullObject, Vector3 transportTo) { if (pushPullObject == null) { return; //Don't even bother... } //Handle PlayerSync and CustomNetTransform (No shared base class, so terrible duping time) //Player objects get PlayerSync var playerSync = pushPullObject.GetComponent <PlayerSync>(); if (playerSync != null) { playerSync.DisappearFromWorldServer(); playerSync.AppearAtPositionServer(transportTo); playerSync.RollbackPrediction(); } //Object and Item objects get CustomNetTransform var customNetTransform = pushPullObject.GetComponent <CustomNetTransform>(); if (customNetTransform != null) { customNetTransform.DisappearFromWorldServer(); customNetTransform.AppearAtPositionServer(transportTo); customNetTransform.RollbackPrediction(); } }
public bool IsNoGravityAt(Vector3Int position, bool isServer) { for (var i = 0; i < LayersKeys.Length; i++) { LayerType layer = LayersKeys[i]; if (layer != LayerType.Objects && HasTile(position, layer, isServer)) { return(false); } if (layer == LayerType.Objects) { foreach (RegisterTile o in isServer ? ((ObjectLayer)LayersValues[i]).ServerObjects.Get(position) : ((ObjectLayer)LayersValues[i]).ClientObjects.Get(position)) { if (o is RegisterObject) { PushPull pushPull = o.GetComponent <PushPull>(); if (!pushPull) { return(o.IsPassable(isServer)); } if (pushPull.isNotPushable) { return(false); } } } } } return(true); }
protected RangeRelationship(RegisterTile obj1, RegisterTile obj2, float maxRange, Action <RangeRelationship> onRangeExceeded) : base(obj1, obj2) { this.maxRange = maxRange; this.onRangeExceeded = onRangeExceeded; pushPull1 = obj1.GetComponent <PushPull>(); pushPull2 = obj2.GetComponent <PushPull>(); }
private void Awake() { colliders = GetComponents <Collider2D>(); registerTile = GetComponent <RegisterTile>(); objectActions = GetComponent <PushPull>(); closetControl = GetComponent <ClosetControl>(); }
private void Awake() { doorClosed = spriteRenderer != null ? spriteRenderer.sprite : null; registerTile = GetComponent <RegisterCloset>(); pushPull = GetComponent <PushPull>(); GetComponent <Integrity>().OnWillDestroyServer.AddListener(OnWillDestroyServer); }
private void DespawnItem(PushPull item, HashSet <GameObject> alreadySold) { item.registerTile.UnregisterClient(); item.registerTile.UnregisterServer(); alreadySold.Add(item.gameObject); Despawn.ServerSingle(item.gameObject); }
private void CheckInitiatePull() { //checks if there is anything in reach we can drag var topObject = MouseUtils.GetOrderedObjectsUnderMouse(null, go => go.GetComponent <PushPull>() != null).FirstOrDefault(); if (topObject != null) { PushPull pushPull = null; // If the topObject has a PlayerMove, we check if he is buckled // The PushPull object we want in this case, is the chair/object on which he is buckled to if (topObject.TryGetComponent <PlayerMove>(out var playerMove) && playerMove.IsBuckled) { pushPull = playerMove.BuckledObject.GetComponent <PushPull>(); } else { pushPull = topObject.GetComponent <PushPull>(); } if (pushPull != null) { pushPull.TryPullThis(); } }
public bool IsNoGravityAt(Vector3Int position) { for (var i = 0; i < LayersKeys.Length; i++) { LayerType layer = LayersKeys[i]; if (layer != LayerType.Objects && HasTile(position, layer)) { return(false); } if (layer == LayerType.Objects) { var objects = ((ObjectLayer)LayersValues[i]).Objects.Get(position); for (var j = 0; j < objects.Count; j++) { RegisterTile o = objects[j]; if (o is RegisterObject) { PushPull pushPull = o.GetComponent <PushPull>(); if (!pushPull || pushPull.isNotPushable) { return(false); } } } } } return(true); }
public bool StartFollowing(PushPull attachTo) { if (attachTo == this) { return(false); } //if attached to someone else: if (IsBeingPulled) { StopFollowing(); } bool chooChooTrain = attachTo.IsBeingPulled && attachTo.PulledBy != this; //if puller can reach this + not trying to pull himself + not being pulled if (PlayerScript.IsInReach(attachTo.registerTile, this.registerTile, true) && attachTo != this && (!attachTo.IsBeingPulled || chooChooTrain)) { Logger.LogTraceFormat("{0} started following {1}", Category.PushPull, this.gameObject.name, attachTo.gameObject.name); PulledBy = attachTo; return(true); } return(false); }
public void CmdStopPulling(GameObject obj) { if (!isPulling) { return; } isPulling = false; PushPull pulled = obj.GetComponent <PushPull>(); pulled.RpcToggleCnt(true); //Cache value for new players pulled.custNetActiveState = true; if (pulled != null) { // //this triggers currentPos syncvar hook to make sure registertile is been completed on all clients // pulled.currentPos = pulled.transform.position; IPlayerSync pS = gameObject.GetComponent <IPlayerSync>(); pS.PullObjectID = NetworkInstanceId.Invalid; pulled.pulledBy = null; } var netTransform = obj.GetComponent <CustomNetTransform>(); if (netTransform != null) { netTransform.SetPosition(obj.transform.localPosition); } }
private void Start() { //Init pending actions queue for your local player if (isLocalPlayer) { pendingActions = new Queue <PlayerAction>(); UpdatePredictedState(); } //Init pending actions queue for server if (isServer) { serverPendingActions = new Queue <PlayerAction>(); } playerScript = GetComponent <PlayerScript>(); playerSprites = GetComponent <PlayerSprites>(); healthBehaviorScript = GetComponent <LivingHealthBehaviour>(); registerTile = GetComponent <RegisterTile>(); pushPull = GetComponent <PushPull>(); //Sub to matrix rotation events via the registerTile because it always has the //correct matrix if (ROTATE_AT_END) { registerTile.OnRotateEnd.AddListener(OnRotation); } else { registerTile.OnRotateStart.AddListener(OnRotation); } }
private void Awake() { electricalNodeControl = GetComponent <ElectricalNodeControl>(); moduleSupplyingDevice = GetComponent <ModuleSupplyingDevice>(); pushPull = GetComponent <PushPull>(); registerTile = GetComponent <RegisterTile>(); }
protected virtual void Awake() { registerObject = GetComponent <RegisterObject>(); directional = GetComponent <Directional>(); drawerPushPull = GetComponent <PushPull>(); drawerSpriteHandler = GetComponentInChildren <SpriteHandler>(); }
/// <summary> /// Does nothing if this is the local player (unless player is in crit). /// /// Invoked when currentDirection syncvar changes. Update the direction of this player to face the specified /// direction. However, if this is the local player's body that is not in crit or a player being pulled by the local player, /// nothing is done and we stick with whatever direction we had already set for them locally (this is to avoid /// glitchy changes in facing direction caused by latency in the syncvar). /// </summary> /// <param name="dir"></param> protected override void FaceDirectionSync(Orientation dir) { //ignore this while we are rotating in a matrix if (isMatrixRotating) { return; } // //don't sync facing direction for players you're pulling locally, unless you're standing still PushPull localPlayer = PlayerManager.LocalPlayerScript ? PlayerManager.LocalPlayerScript.pushPull : null; if (localPlayer && localPlayer.Pushable != null && localPlayer.Pushable.IsMovingClient) { if (playerMove && playerMove.PlayerScript && playerMove.PlayerScript.pushPull && playerMove.PlayerScript.pushPull.IsPulledByClient(localPlayer)) { return; } } //check if we are crit, or else our direction might be out of sync with the server if (PlayerManager.LocalPlayer != gameObject || playerHealth.IsCrit || playerHealth.IsSoftCrit) { currentDirection = dir; SetDir(dir); } }
public void PullReset(NetworkInstanceId netID) { PullObjectID = netID; transform.hasChanged = false; if (netID == NetworkInstanceId.Invalid) { if (PullingObject != null) { pullRegister.UpdatePosition(); //Could be another player PlayerSync otherPlayerSync = PullingObject.GetComponent <PlayerSync>(); if (otherPlayerSync != null) { CmdSetPositionFromReset(gameObject, otherPlayerSync.gameObject, PullingObject.transform.position); } } pullRegister = null; PullingObject = null; } else { PullingObject = ClientScene.FindLocalObject(netID); PushPull oA = PullingObject.GetComponent <PushPull>(); pullPos = PullingObject.transform.localPosition; if (oA != null) { oA.pulledBy = gameObject; } pullRegister = PullingObject.GetComponent <RegisterTile>(); } }
protected virtual void Awake() { registerObject = GetComponent <RegisterObject>(); rotatable = GetComponent <Rotatable>(); drawerPushPull = GetComponent <PushPull>(); container = GetComponent <ObjectContainer>(); drawerSpriteHandler = GetComponentInChildren <SpriteHandler>(); }
private void UninformHead(PushPull whoToInform, PushPull subject) { InformPullMessage.Send(whoToInform, subject, null); if (IsPullingSomethingServer) { PulledObjectServer.UninformHead(whoToInform, PulledObjectServer); } }
void Start() { rm = GetComponent <RoyMove>(); anim = GetComponent <Animator>(); pfsg = 0; pushll = GetComponent <PushPull>(); canInput = true; }
// Start is called before the first frame update void Start() { orgScale = transform.localScale; flippedScale = new Vector3(-orgScale.x, orgScale.y, orgScale.z); anim.SetFloat("facingRight", 1); rb = GetComponent <Rigidbody2D>(); pushPull = GetComponent <PushPull>(); }
private void Start() { playerSprites = gameObject.GetComponent <PlayerSprites>(); playerSync = GetComponent <PlayerSync>(); pushPull = GetComponent <PushPull>(); registerTile = GetComponent <RegisterTile>(); pna = gameObject.GetComponent <PlayerNetworkActions>(); }
private void Awake() { directional = GetComponent <Directional>(); pushPull = GetComponent <PushPull>(); registerTile = GetComponent <RegisterTile>(); accessRestrictions = GetComponent <AccessRestrictions>(); electricalNodeControl = GetComponent <ElectricalNodeControl>(); spriteHandler = GetComponentInChildren <SpriteHandler>(); }
protected void MakeContentVisible() { var netTransform = content.gameObject.GetComponent <CustomNetTransform>(); var pos = gameObject.RegisterTile().WorldPositionServer; content.parentContainer = null; netTransform.AppearAtPositionServer(pos); content = null; }
public void CmdTryPush(GameObject obj, Vector3 pos) { PushPull pushed = obj.GetComponent <PushPull>(); if (pushed != null) { pushed.serverPos = pos; } }
public void CmdStopOtherPulling(GameObject obj) { PushPull objA = obj.GetComponent <PushPull>(); if (objA.pulledBy != null) { objA.pulledBy.GetComponent <PlayerNetworkActions>().CmdStopPulling(obj); } }
private SpawnDestination(Vector3 worldPosition, Transform parent, Quaternion localRotation, bool cancelIfImpassable, PushPull sharePosition = null) { WorldPosition = worldPosition; Parent = parent; LocalRotation = localRotation; CancelIfImpassable = cancelIfImpassable; SharePosition = sharePosition; }
private void UpdatePullingUI(PushPull pull) { ConnectedPlayer player = PlayerList.Instance.Get(pull.gameObject); if (player != ConnectedPlayer.Invalid) { TargetUpdatePullingUI(player.Connection, pull.IsPullingSomethingServer); } }
/// (Eventually) public bool IsPulledByClient(PushPull pushPull) { if (!IsBeingPulledClient) { return(false); } return(PulledByClient == pushPull || PulledByClient.IsPulledByClient(pushPull)); }
// Start is called before the first frame update void Start() { bm = GetComponent <BaseMovement>(); anim = GetComponent <Animator>(); rb = GetComponent <Rigidbody2D>(); pfsg = 0; pushll = GetComponent <PushPull>(); canInput = true; }
public void SetContent(GameObject toWrap) { content = toWrap.GetComponent <PushPull>(); var exportCost = toWrap.GetComponent <Attributes>().ExportCost; UpdateExportCost(exportCost); content.parentContainer = pushPull; content.VisibleState = false; }
private void EnsureInit() { if (registerTile != null) { return; } registerTile = GetComponent <RegisterCloset>(); pushPull = GetComponent <PushPull>(); }