Beispiel #1
0
    private IEnumerator CritHonk(PositionalHandApply clickData, LivingHealthBehaviour targetHealth)
    {
        yield return(WaitFor.Seconds(0.02f));

        SoundManager.PlayNetworkedAtPos(Sound, gameObject.AssumedWorldPosServer(), -1f, true, true, 20, 5);
        targetHealth.ApplyDamage(clickData.Performer, CritDamage, AttackType.Energy, DamageType.Brute, BodyPartType.Head);
    }
        private void CreateRecord(LivingHealthBehaviour mob, PlayerScript playerScript)
        {
            var record = new CloningRecord();

            record.UpdateRecord(mob, playerScript);
            cloningRecords.Add(record);
        }
Beispiel #3
0
    protected void Awake()
    {
        directional           = GetComponent <Directional>();
        livingHealthBehaviour = GetComponent <LivingHealthBehaviour>();

        foreach (ClothingItem c in GetComponentsInChildren <ClothingItem>())
        {
            clothes[c.name] = c;
            // add listener in case clothing was changed
            c.OnClothingEquiped += OnClothingEquipped;
        }

        //TODO: Remove Resources.Load calls, change to prefab references stored somewhere
        if (ENGULFED_BURNING_OVERLAY_PREFAB == null)
        {
            ENGULFED_BURNING_OVERLAY_PREFAB = Resources.Load <GameObject>("EngulfedBurningPlayer");
            PARTIAL_BURNING_OVERLAY_PREFAB  = Resources.Load <GameObject>("PartialBurningPlayer");
            ELECTROCUTED_OVERLAY_PREFAB     = Resources.Load <GameObject>("ElectrocutedHumanoid");
        }

        AddOverlayGameObjects();

        directional.OnDirectionChange.AddListener(OnDirectionChange);
        livingHealthBehaviour.OnClientFireStacksChange.AddListener(OnClientFireStacksChange);
        OnClientFireStacksChange(livingHealthBehaviour.FireStacks);
    }
Beispiel #4
0
 private void Awake()
 {
     registerTile = GetComponent <RegisterTile>();
     cnt          = GetComponent <CustomNetTransform>();
     dirSprites   = GetComponent <NPCDirectionalSprites>();
     health       = GetComponent <LivingHealthBehaviour>();
 }
Beispiel #5
0
        protected override void ActOnLiving(Vector3 dir, LivingHealthBehaviour healthBehaviour)
        {
            var ctc = healthBehaviour.connectionToClient;
            var rtt = healthBehaviour.RTT;
            var pos = healthBehaviour.GetComponent <RegisterTile>().WorldPositionServer;

            _ = AttackFleshRoutine(dir, healthBehaviour, null, pos, ctc, rtt);
        }
Beispiel #6
0
 void Awake()
 {
     cnt         = GetComponent <CustomNetTransform>();
     registerObj = GetComponent <RegisterObject>();
     dirSprites  = GetComponent <NPCDirectionalSprites>();
     health      = GetComponent <LivingHealthBehaviour>();
     agentParameters.onDemandDecision = true;
 }
Beispiel #7
0
 void Awake()
 {
     bloodSystem           = GetComponent <BloodSystem>();
     livingHealthBehaviour = GetComponent <LivingHealthBehaviour>();
     playerScript          = GetComponent <PlayerScript>();
     equipment             = GetComponent <Equipment>();
     objectBehaviour       = GetComponent <ObjectBehaviour>();
 }
Beispiel #8
0
 void Awake()
 {
     cnt         = GetComponent <CustomNetTransform>();
     registerObj = GetComponent <RegisterObject>();
     directional = GetComponent <Directional>();
     health      = GetComponent <LivingHealthBehaviour>();
     integrity   = GetComponent <Integrity>();
     agentParameters.onDemandDecision = true;
 }
Beispiel #9
0
 private void EnsureInit()
 {
     if (health != null)
     {
         return;
     }
     health         = GetComponent <LivingHealthBehaviour>();
     uprightSprites = GetComponent <UprightSprites>();
 }
Beispiel #10
0
    private void DamageOnClose()
    {
        var healthBehaviours = matrix.Get <LivingHealthBehaviour>(registerTile.Position);

        for (var i = 0; i < healthBehaviours.Count; i++)
        {
            LivingHealthBehaviour healthBehaviour = healthBehaviours[i];
            healthBehaviour.ApplyDamage(gameObject, 500, DamageType.Brute);
        }
    }
Beispiel #11
0
 protected virtual void Awake()
 {
     mobFollow      = GetComponent <MobFollow>();
     mobExplore     = GetComponent <MobExplore>();
     mobFlee        = GetComponent <MobFlee>();
     health         = GetComponent <LivingHealthBehaviour>();
     dirSprites     = GetComponent <NPCDirectionalSprites>();
     cnt            = GetComponent <CustomNetTransform>();
     registerObject = GetComponent <RegisterObject>();
 }
Beispiel #12
0
    private IEnumerator CritHonk(PositionalHandApply clickData, LivingHealthBehaviour targetHealth)
    {
        yield return(WaitFor.Seconds(0.02f));

        AudioSourceParameters audioSourceParameters = new AudioSourceParameters(pitch: -1f);         //This plays it backwards, is that what you wanted?
        ShakeParameters       shakeParameters       = new ShakeParameters(true, 20, 5);

        SoundManager.PlayNetworkedAtPos(SingletonSOSounds.Instance.ClownHonk, gameObject.AssumedWorldPosServer(), audioSourceParameters, true, sourceObj: GetHonkSoundObject(), shakeParameters: shakeParameters);
        targetHealth.ApplyDamageToBodypart(clickData.Performer, CritDamage, AttackType.Energy, DamageType.Brute, BodyPartType.Head);
    }
Beispiel #13
0
        private void EnsureInit()
        {
            if (health != null)
            {
                return;
            }
            health    = GetComponent <LivingHealthBehaviour>();
            rotatable = GetComponent <Rotatable>();

            rotatable.OnRotationChange.AddListener(OnDirectionChange);
        }
Beispiel #14
0
    /// Lists objects to be damaged on given tile. Prob should be moved elsewhere
    private bool HittingSomething(Vector3Int atPos, GameObject thrownBy, out List <LivingHealthBehaviour> victims)
    {
        //Not damaging anything at launch tile
        if (Vector3Int.RoundToInt(serverState.ActiveThrow.OriginPos) == atPos)
        {
            victims = null;
            return(false);
        }
        var objectsOnTile = MatrixManager.GetAt <LivingHealthBehaviour>(atPos);

        if (objectsOnTile != null)
        {
            var damageables = new List <LivingHealthBehaviour>();
            for (var i = 0; i < objectsOnTile.Count; i++)
            {
                LivingHealthBehaviour obj = objectsOnTile[i];
//Skip thrower for now
                if (obj.gameObject == thrownBy)
                {
                    Logger.Log($"{thrownBy.name} not hurting himself", Category.Throwing);
                    continue;
                }

                //Skip dead bodies
                if (obj.IsDead)
                {
                    continue;
                }

                var commonTransform = obj.GetComponent <IPushable>();
                if (commonTransform != null)
                {
                    if (this.ServerImpulse.To2Int() == commonTransform.ServerImpulse.To2Int() &&
                        this.SpeedServer <= commonTransform.SpeedServer)
                    {
                        Logger.LogTraceFormat("{0} not hitting {1} as they fly in the same direction", Category.Throwing, gameObject.name,
                                              obj.gameObject.name);
                        continue;
                    }
                }

                damageables.Add(obj);
            }

            if (damageables.Count > 0)
            {
                victims = damageables;
                return(true);
            }
        }

        victims = null;
        return(false);
    }
Beispiel #15
0
 public void UpdateRecord(LivingHealthBehaviour mob, PlayerScript playerScript)
 {
     mobID             = mob.mobID;
     mind              = playerScript.mind;
     name              = playerScript.playerName;
     characterSettings = playerScript.characterSettings;
     oxyDmg            = mob.bloodSystem.oxygenDamage;
     burnDmg           = mob.GetTotalBurnDamage();
     toxinDmg          = 0;
     bruteDmg          = mob.GetTotalBruteDamage();
     uniqueIdentifier  = "35562Eb18150514630991";
 }
Beispiel #16
0
        private void EnsureInit()
        {
            if (health != null)
            {
                return;
            }
            health            = GetComponent <LivingHealthBehaviour>();
            directional       = GetComponent <Directional>();
            directionalSprite = GetComponent <DirectionalSpriteV2>();

            directional.OnDirectionChange.AddListener(OnDirectionChange);
        }
Beispiel #17
0
    public void ServerPerformInteraction(PositionalHandApply interaction)
    {
        bool emptyHand = interaction.HandSlot.IsEmpty;
        var  wna       = interaction.Performer.GetComponent <WeaponNetworkActions>();

        if (interactableTiles != null && !emptyHand)
        {
            //attacking tiles
            var tileAt = interactableTiles.LayerTileAt(interaction.WorldPositionTarget, true);
            if (tileAt == null)
            {
                return;
            }
            if (tileAt.TileType == TileType.Wall)
            {
                return;
            }
            wna.ServerPerformMeleeAttack(gameObject, interaction.TargetVector, BodyPartType.None, tileAt.LayerType);
        }
        else
        {
            //attacking objects

            //butcher check
            GameObject victim          = interaction.TargetObject;
            var        healthComponent = victim.GetComponent <LivingHealthBehaviour>();
            if (healthComponent && healthComponent.allowKnifeHarvest && healthComponent.IsDead && Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Knife) && interaction.Intent == Intent.Harm)
            {
                GameObject performer = interaction.Performer;

                void ProgressFinishAction()
                {
                    LivingHealthBehaviour victimHealth = victim.GetComponent <LivingHealthBehaviour>();

                    victimHealth.Harvest();
                    SoundManager.PlayNetworkedAtPos(butcherSound, victim.RegisterTile().WorldPositionServer);
                }

                var bar = StandardProgressAction.Create(ProgressConfig, ProgressFinishAction)
                          .ServerStartProgress(victim.RegisterTile(), butcherTime, performer);
            }
            else
            {
                if (gameObject.GetComponent <Integrity>() && emptyHand)
                {
                    return;
                }

                wna.ServerPerformMeleeAttack(gameObject, interaction.TargetVector, interaction.TargetBodyPart, LayerType.None);
            }
        }
    }
Beispiel #18
0
 protected virtual void Awake()
 {
     simpleAnimal   = GetComponent <SimpleAnimal>();
     mobFollow      = GetComponent <MobFollow>();
     mobExplore     = GetComponent <MobExplore>();
     mobFlee        = GetComponent <MobFlee>();
     health         = GetComponent <LivingHealthBehaviour>();
     directional    = GetComponent <Directional>();
     mobSprite      = GetComponent <MobSprite>();
     cnt            = GetComponent <CustomNetTransform>();
     registerObject = GetComponent <RegisterObject>();
     uprightSprites = GetComponent <UprightSprites>();
 }
Beispiel #19
0
 public override void HandleItems()
 {
     base.HandleItems();
     if (heldPlayers.Count > 0)
     {
         var mob = heldPlayers[0];
         occupant = mob.GetComponent <LivingHealthBehaviour>();
     }
     else
     {
         occupant = null;
     }
 }
Beispiel #20
0
 protected override void ServerHandleContentsOnStatusChange(bool willClose)
 {
     base.ServerHandleContentsOnStatusChange(willClose);
     if (ServerHeldPlayers.Any())
     {
         var mob = ServerHeldPlayers.First();
         occupant = mob.GetComponent <LivingHealthBehaviour>();
     }
     else
     {
         occupant = null;
     }
 }
Beispiel #21
0
        //We need to slow the attack down because clients are behind server
        private async Task AttackFleshRoutine(Vector2 dir, LivingHealthBehaviour targetHealth, LivingHealthMasterBase livingHealth,
                                              Vector3 worldPos, NetworkConnection ctc, float rtt)
        {
            if (targetHealth == null && livingHealth == null)
            {
                return;
            }
            if (ctc == null)
            {
                return;
            }

            ServerDoLerpAnimation(dir);

            if (PlayerManager.LocalPlayerScript != null &&
                PlayerManager.LocalPlayerScript.playerHealth != null &&
                PlayerManager.LocalPlayerScript.playerHealth == livingHealth ||
                rtt < 0.02f)
            {
                //Wait until the end of the frame
                await Task.Delay(1);
            }
            else
            {
                //Wait until RTT/2 seconds?
                Logger.Log($"WAIT FOR ATTACK: {rtt / 2f}", Category.Mobs);
                await Task.Delay((int)(rtt * 500));
            }

            if (Vector3.Distance(mobTile.WorldPositionServer, worldPos) < 1.5f)
            {
                var bodyPartTarget = defaultTarget.Randomize();
                if (targetHealth != null)
                {
                    targetHealth.ApplyDamageToBodyPart(gameObject, hitDamage, AttackType.Melee, DamageType.Brute,
                                                       bodyPartTarget);
                    Chat.AddAttackMsgToChat(gameObject, targetHealth.gameObject, bodyPartTarget, null, attackVerb);
                }
                else
                {
                    livingHealth.ApplyDamageToBodyPart(gameObject, hitDamage, AttackType.Melee, DamageType.Brute,
                                                       bodyPartTarget);
                    Chat.AddAttackMsgToChat(gameObject, livingHealth.gameObject, bodyPartTarget, null, attackVerb);
                }
                SoundManager.PlayNetworkedAtPos(attackSound, mobTile.WorldPositionServer, sourceObj: gameObject);
            }
        }
Beispiel #22
0
        private void TryFacehug(Vector3 dir, LivingHealthBehaviour player)
        {
            var playerInventory = player.gameObject.GetComponent <PlayerScript>()?.Equipment;

            if (playerInventory == null)
            {
                return;
            }

            string verb;
            bool   success;

            if (HasAntihuggerItem(playerInventory))
            {
                verb    = "tried to hug";
                success = false;
            }
            else
            {
                verb    = "hugged";
                success = true;
            }

            mobMeleeAction.ServerDoLerpAnimation(dir);

            Chat.AddAttackMsgToChat(
                gameObject,
                player.gameObject,
                BodyPartType.Head,
                null,
                verb);

            SoundManager.PlayNetworkedAtPos(
                "bite",
                player.gameObject.RegisterTile().WorldPositionServer,
                1f,
                true,
                player.gameObject);

            if (success)
            {
                RegisterPlayer registerPlayer = player.gameObject.GetComponent <RegisterPlayer>();
                Facehug(playerInventory, registerPlayer);
            }
        }
Beispiel #23
0
    protected void Awake()
    {
        directional           = GetComponent <Directional>();
        livingHealthBehaviour = GetComponent <LivingHealthBehaviour>();

        foreach (ClothingItem c in GetComponentsInChildren <ClothingItem>())
        {
            clothes[c.name] = c;
            // add listener in case clothing was changed
            c.OnClothingEquipped += OnClothingEquipped;
        }

        AddOverlayGameObjects();

        directional.OnDirectionChange.AddListener(OnDirectionChange);
        livingHealthBehaviour.OnClientFireStacksChange.AddListener(OnClientFireStacksChange);
        OnClientFireStacksChange(livingHealthBehaviour.FireStacks);
    }
Beispiel #24
0
 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>();
 }
Beispiel #25
0
    void InitSystem()
    {
        playerScript          = GetComponent <PlayerScript>();
        bloodSystem           = GetComponent <BloodSystem>();
        respiratorySystem     = GetComponent <RespiratorySystem>();
        livingHealthBehaviour = GetComponent <LivingHealthBehaviour>();

        //Server only
        if (CustomNetworkManager.Instance._isServer)
        {
            //Spawn a brain and connect the brain to this living entity
            brain = new Brain();
            brain.ConnectBrainToBody(gameObject);
            if (playerScript != null)
            {
                //TODO: See https://github.com/unitystation/unitystation/issues/1429
            }
            init = true;
        }
    }
Beispiel #26
0
    private void OnStartPlayerCremation()
    {
        var containsConsciousPlayer = false;

        foreach (ObjectBehaviour player in serverHeldPlayers)
        {
            LivingHealthBehaviour playerLHB = player.GetComponent <LivingHealthBehaviour>();
            if (playerLHB.ConsciousState == ConsciousState.CONSCIOUS ||
                playerLHB.ConsciousState == ConsciousState.BARELY_CONSCIOUS)
            {
                containsConsciousPlayer = true;
            }
        }

        if (containsConsciousPlayer)
        {
            // This is an incredibly brutal SFX... it also needs chopping up.
            // SoundManager.PlayNetworkedAtPos("ShyguyScream", DrawerWorldPosition, sourceObj: gameObject);
        }
    }
Beispiel #27
0
    /// <summary>
    /// Electrocutes a player, applying effects to the victim
    /// depending on the electrocution power.
    /// </summary>
    /// <param name="player">The player GameObject to electrocute></param>
    /// <param name="shockSourcePos">The Vector3Int position of the voltage source</param>
    /// <param name="shockSourceName">The name of the voltage source</param>
    /// <param name="voltage">The voltage the victim receives</param>
    /// <returns>Severity enumerable</returns>
    public Severity ElectrocutePlayer(GameObject player, Vector2 shockSourcePos,
                                      string shockSourceName, float voltage)
    {
        victim               = player;
        victimLHB            = player.GetComponent <LivingHealthBehaviour>();
        victimScript         = player.GetComponent <PlayerScript>();
        this.shockSourcePos  = shockSourcePos;
        this.shockSourceName = shockSourceName;

        if (victim.GetComponent <PlayerNetworkActions>().activeHand == NamedSlot.leftHand)
        {
            playerActiveHand = BodyPartType.LeftArm;
        }
        else
        {
            playerActiveHand = BodyPartType.RightArm;
        }

        switch (GetPlayerSeverity(victim, voltage))
        {
        case Severity.None:
            break;

        case Severity.Mild:
            PlayerMildElectrocution();
            break;

        case Severity.Painful:
            PlayerPainfulElectrocution();
            break;

        case Severity.Lethal:
            PlayerLethalElectrocution();
            break;
        }

        return(severity);
    }
Beispiel #28
0
    public void Should_Not_Damage_Player_Through_Wall()
    {
        GameObject player = new GameObject();

        player.AddComponent <BoxCollider2D>();
        player.AddComponent <LivingHealthBehaviour>();
        player.layer = LayerMask.NameToLayer("Players");
        player.transform.position = new Vector3(2, 0);

        GameObject wall = new GameObject();

        wall.AddComponent <BoxCollider2D>();
        wall.layer = LayerMask.NameToLayer("Walls");
        wall.transform.position = new Vector3(1, 0);

        LivingHealthBehaviour damaged = null;

        subject.callback = t => damaged = t;

        subject.CalcAndApplyExplosionDamage(null);

        Assert.That(damaged == null);
    }
Beispiel #29
0
    public void Awake()
    {
        if (Animations == null)
        {
            return;
        }

        npcDirectionalSprite = GetComponent <NPCDirectionalSprites>();

        livingHealthBehaviour = GetComponent <LivingHealthBehaviour>();

        simpleAnimal = GetComponent <SimpleAnimal>();

        foreach (var AnimationEntry in Animations)
        {
            if (AnimationEntry.Sprites == null)
            {
                return;
            }
            LoadedSprites.Add(Count, new Tuple <Sprite[], bool, bool, bool, float, List <int> >(AnimationEntry.Sprites, AnimationEntry.Simple, AnimationEntry.SimpleResetDirection, AnimationEntry.IsDeathAnimation, AnimationEntry.Speed, AnimationEntry.ComplexAnimationIndex));
            Count += 1;
        }
    }
Beispiel #30
0
    protected void Awake()
    {
        if (ENGULFED_BURNING_OVERLAY_PREFAB == null)
        {
            ENGULFED_BURNING_OVERLAY_PREFAB = Resources.Load <GameObject>("EngulfedBurningPlayer");
            PARTIAL_BURNING_OVERLAY_PREFAB  = Resources.Load <GameObject>("PartialBurningPlayer");
        }

        if (engulfedBurningOverlay == null)
        {
            engulfedBurningOverlay = GameObject.Instantiate(ENGULFED_BURNING_OVERLAY_PREFAB, transform)
                                     .GetComponent <BurningDirectionalOverlay>();
            engulfedBurningOverlay.enabled = true;
            engulfedBurningOverlay.StopBurning();
            partialBurningOverlay = GameObject.Instantiate(PARTIAL_BURNING_OVERLAY_PREFAB, transform)
                                    .GetComponent <BurningDirectionalOverlay>();
            partialBurningOverlay.enabled = true;
            partialBurningOverlay.StopBurning();
        }

        livingHealthBehaviour = GetComponent <LivingHealthBehaviour>();
        livingHealthBehaviour.OnClientFireStacksChange.AddListener(OnClientFireStacksChange);
        OnClientFireStacksChange(livingHealthBehaviour.FireStacks);

        //StaticSpriteHandler

        directional = GetComponent <Directional>();
        directional.OnDirectionChange.AddListener(OnDirectionChange);
        foreach (ClothingItem c in GetComponentsInChildren <ClothingItem>())
        {
            clothes[c.name] = c;
            // add listner in case clothing was changed
            c.OnClothingEquiped += OnClothingEquipped;
        }

        SetupBodySprites();
    }