// Check for access to object
        private static Boolean isValidRayCastTarget()
        {
            Boolean hitValid = true;

            if (HitPiece.m_onlyInTeleportArea && !EffectArea.IsPointInsideArea(HitPiece.transform.position, EffectArea.Type.Teleport, 0f))
            {
                // Not in Teleport Area
                hitValid = false;
            }
            if (!HitPiece.m_allowedInDungeons && (HitPiece.transform.position.y > 3000f))
            {
                // Not in dungeon
                hitValid = false;
            }
            if (Location.IsInsideNoBuildLocation(HitPiece.transform.position))
            {
                // No build zone
                hitValid = false;
            }
            float radius = HitPiece.GetComponent <PrivateArea>() ? HitPiece.GetComponent <PrivateArea>().m_radius : 0f;

            if (!PrivateArea.CheckAccess(HitPiece.transform.position, radius, true))
            {
                // private zone
                hitValid = false;
            }

            return(hitValid);
        }
        private static Boolean isValidPlacement()
        {
            bool water = component.m_waterPiece || component.m_noInWater;

            PlayerInstance.m_placementStatus = 0;

            if (component.m_groundOnly || component.m_groundPiece || component.m_cultivatedGroundOnly)
            {
                PlayerInstance.m_placementMarkerInstance.SetActive(false);
            }

            StationExtension component2 = component.GetComponent <StationExtension>();

            if (component2 != null)
            {
                CraftingStation craftingStation = component2.FindClosestStationInRange(component.transform.position);
                if (craftingStation)
                {
                    component2.StartConnectionEffect(craftingStation);
                }
                else
                {
                    component2.StopConnectionEffect();
                    PlayerInstance.m_placementStatus = Player.PlacementStatus.ExtensionMissingStation; // Missing Station
                }
                if (component2.OtherExtensionInRange(component.m_spaceRequirement))
                {
                    PlayerInstance.m_placementStatus = Player.PlacementStatus.MoreSpace; // More Space
                }
            }

            if (component.m_onlyInTeleportArea && !EffectArea.IsPointInsideArea(component.transform.position, EffectArea.Type.Teleport, 0f))
            {
                PlayerInstance.m_placementStatus = Player.PlacementStatus.NoTeleportArea;
            }
            if (!component.m_allowedInDungeons && (component.transform.position.y > 3000f))
            {
                PlayerInstance.m_placementStatus = Player.PlacementStatus.NotInDungeon;
            }
            if (Location.IsInsideNoBuildLocation(PlayerInstance.m_placementGhost.transform.position))
            {
                PlayerInstance.m_placementStatus = Player.PlacementStatus.NoBuildZone;
            }
            float radius = component.GetComponent <PrivateArea>() ? component.GetComponent <PrivateArea>().m_radius : 0f;

            if (!PrivateArea.CheckAccess(PlayerInstance.m_placementGhost.transform.position, radius, true))
            {
                PlayerInstance.m_placementStatus = Player.PlacementStatus.PrivateZone;
            }

            if (PlayerInstance.m_placementStatus != 0)
            {
                component.SetInvalidPlacementHeightlight(true);
            }
            else
            {
                component.SetInvalidPlacementHeightlight(false);
            }
            return(true);
        }
示例#3
0
    // Token: 0x06000478 RID: 1144 RVA: 0x000241D0 File Offset: 0x000223D0
    private void PlaceOne()
    {
        Vector3 vector;

        if (this.GetRandomPoint(base.transform.position, this.m_totalRadius, out vector))
        {
            int   num  = 0;
            float num2 = 6.2831855f / (float)this.m_rays;
            for (int i = 0; i < this.m_rays; i++)
            {
                float angle = (float)i * num2;
                if ((double)this.GetPointOnEdge(vector, angle, this.m_testRadius).y < (double)vector.y - 0.1)
                {
                    num++;
                }
            }
            if (num > this.m_rays / 4)
            {
                return;
            }
            if (EffectArea.IsPointInsideArea(vector, EffectArea.Type.Fire, this.m_testRadius))
            {
                return;
            }
            ParticleSystem.EmitParams emitParams = default(ParticleSystem.EmitParams);
            emitParams.position = vector + Vector3.up * this.m_placeOffset;
            this.m_psystem.Emit(emitParams, 1);
        }
    }
 // Token: 0x0600067A RID: 1658 RVA: 0x00036428 File Offset: 0x00034628
 private void CheckFire()
 {
     this.m_haveFire = EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.Burning, 0.25f);
     if (this.m_haveFireObject)
     {
         this.m_haveFireObject.SetActive(this.m_haveFire);
     }
 }
示例#5
0
 // Token: 0x06000C65 RID: 3173 RVA: 0x00059063 File Offset: 0x00057263
 private bool CheckFire(Player human)
 {
     if (!EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.Heat, 0f))
     {
         human.Message(MessageHud.MessageType.Center, "$msg_bednofire", 0, null);
         return(false);
     }
     return(true);
 }
示例#6
0
            static bool AvoidFire(MonsterAI instance, float dt, Vector3 targetPosition)
            {
                EffectArea effectArea2 = EffectArea.IsPointInsideArea(instance.transform.position, EffectArea.Type.Burning, 2f);

                if ((bool)effectArea2)
                {
                    typeof(MonsterAI).GetMethod("RandomMovementArroundPoint", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(instance, new object[] { dt, effectArea2.transform.position, effectArea2.GetRadius() + 3f, true });
                    return(true);
                }
                return(false);
            }
示例#7
0
        public bool AvoidFire(float dt)
        {
            EffectArea effectArea2 = EffectArea.IsPointInsideArea(Instance.transform.position, EffectArea.Type.Burning, 2f);

            if ((bool)effectArea2)
            {
                Invoke <BaseAI>(Instance, "RandomMovementArroundPoint", dt, effectArea2.transform.position, effectArea2.GetRadius() + 3f, true);
                return(true);
            }
            return(false);
        }
    // Token: 0x060000EF RID: 239 RVA: 0x0000714C File Offset: 0x0000534C
    private void UpdateSpawner()
    {
        if (!this.m_nview.IsOwner())
        {
            return;
        }
        ZDOID zdoid = this.m_nview.GetZDO().GetZDOID("spawn_id");

        if (this.m_respawnTimeMinuts <= 0f && !zdoid.IsNone())
        {
            return;
        }
        if (!zdoid.IsNone() && ZDOMan.instance.GetZDO(zdoid) != null)
        {
            this.m_nview.GetZDO().Set("alive_time", ZNet.instance.GetTime().Ticks);
            return;
        }
        if (this.m_respawnTimeMinuts > 0f)
        {
            DateTime time = ZNet.instance.GetTime();
            DateTime d    = new DateTime(this.m_nview.GetZDO().GetLong("alive_time", 0L));
            if ((time - d).TotalMinutes < (double)this.m_respawnTimeMinuts)
            {
                return;
            }
        }
        if (!this.m_spawnAtDay && EnvMan.instance.IsDay())
        {
            return;
        }
        if (!this.m_spawnAtNight && EnvMan.instance.IsNight())
        {
            return;
        }
        bool requireSpawnArea = this.m_requireSpawnArea;

        if (!this.m_spawnInPlayerBase && EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.PlayerBase, 0f))
        {
            return;
        }
        if (this.m_triggerNoise > 0f)
        {
            if (!Player.IsPlayerInRange(base.transform.position, this.m_triggerDistance, this.m_triggerNoise))
            {
                return;
            }
        }
        else if (!Player.IsPlayerInRange(base.transform.position, this.m_triggerDistance))
        {
            return;
        }
        this.Spawn();
    }
示例#9
0
 private bool IsInsideBase()
 {
     return((double)this.transform.position.y > (double)ZoneSystem.instance.m_waterLevel - 2.0 && (bool)(UnityEngine.Object)EffectArea.IsPointInsideArea(this.transform.position, EffectArea.Type.PlayerBase, 0.0f));
 }
示例#10
0
    // Token: 0x0600036D RID: 877 RVA: 0x0001D5F4 File Offset: 0x0001B7F4
    protected override void UpdateAI(float dt)
    {
        base.UpdateAI(dt);
        if (!this.m_nview.IsOwner())
        {
            return;
        }
        if (this.IsSleeping())
        {
            this.UpdateSleep(dt);
            return;
        }
        this.m_aiStatus = "";
        Humanoid humanoid = this.m_character as Humanoid;
        bool     flag;
        bool     flag2;

        this.UpdateTarget(humanoid, dt, out flag, out flag2);
        if (this.m_avoidLand && !this.m_character.IsSwiming())
        {
            this.m_aiStatus = "Move to water";
            base.MoveToWater(dt, 20f);
            return;
        }
        if (((this.DespawnInDay() && EnvMan.instance.IsDay()) || (this.IsEventCreature() && !RandEventSystem.HaveActiveEvent())) && (this.m_targetCreature == null || !flag2))
        {
            base.MoveAwayAndDespawn(dt, true);
            this.m_aiStatus = "Trying to despawn ";
            return;
        }
        if (this.m_fleeIfNotAlerted && !this.HuntPlayer() && this.m_targetCreature && !base.IsAlerted() && Vector3.Distance(this.m_targetCreature.transform.position, base.transform.position) - this.m_targetCreature.GetRadius() > this.m_alertRange)
        {
            base.Flee(dt, this.m_targetCreature.transform.position);
            this.m_aiStatus = "Avoiding conflict";
            return;
        }
        if (this.m_fleeIfLowHealth > 0f && this.m_character.GetHealthPercentage() < this.m_fleeIfLowHealth && this.m_timeSinceHurt < 20f && this.m_targetCreature != null)
        {
            base.Flee(dt, this.m_targetCreature.transform.position);
            this.m_aiStatus = "Low health, flee";
            return;
        }
        if ((this.m_afraidOfFire || this.m_avoidFire) && base.AvoidFire(dt, this.m_targetCreature, this.m_afraidOfFire))
        {
            if (this.m_afraidOfFire)
            {
                this.m_targetStatic   = null;
                this.m_targetCreature = null;
            }
            this.m_aiStatus = "Avoiding fire";
            return;
        }
        if (this.m_circleTargetInterval > 0f && this.m_targetCreature)
        {
            if (this.m_targetCreature)
            {
                this.m_pauseTimer += dt;
                if (this.m_pauseTimer > this.m_circleTargetInterval)
                {
                    if (this.m_pauseTimer > this.m_circleTargetInterval + this.m_circleTargetDuration)
                    {
                        this.m_pauseTimer = 0f;
                    }
                    base.RandomMovementArroundPoint(dt, this.m_targetCreature.transform.position, this.m_circleTargetDistance, base.IsAlerted());
                    this.m_aiStatus = "Attack pause";
                    return;
                }
            }
            else
            {
                this.m_pauseTimer = 0f;
            }
        }
        if (this.m_targetCreature != null)
        {
            if (EffectArea.IsPointInsideArea(this.m_targetCreature.transform.position, EffectArea.Type.NoMonsters, 0f))
            {
                base.Flee(dt, this.m_targetCreature.transform.position);
                this.m_aiStatus = "Avoid no-monster area";
                return;
            }
        }
        else
        {
            EffectArea effectArea = EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.NoMonsters, 15f);
            if (effectArea != null)
            {
                base.Flee(dt, effectArea.transform.position);
                this.m_aiStatus = "Avoid no-monster area";
                return;
            }
        }
        if (this.m_fleeIfHurtWhenTargetCantBeReached && this.m_targetCreature != null && !this.m_havePathToTarget && this.m_timeSinceHurt < 20f)
        {
            this.m_aiStatus = "Hide from unreachable target";
            base.Flee(dt, this.m_targetCreature.transform.position);
            return;
        }
        if ((!base.IsAlerted() || (this.m_targetStatic == null && this.m_targetCreature == null)) && this.UpdateConsumeItem(humanoid, dt))
        {
            this.m_aiStatus = "Consume item";
            return;
        }
        ItemDrop.ItemData itemData = this.SelectBestAttack(humanoid, dt);
        bool flag3 = itemData != null && Time.time - itemData.m_lastAttackTime > itemData.m_shared.m_aiAttackInterval && Time.time - this.m_lastAttackTime > this.m_minAttackInterval && !base.IsTakingOff();

        if ((this.m_character.IsFlying() ? this.m_circulateWhileChargingFlying : this.m_circulateWhileCharging) && (this.m_targetStatic != null || this.m_targetCreature != null) && itemData != null && !flag3 && !this.m_character.InAttack())
        {
            this.m_aiStatus = "Move around target weapon ready:" + flag3.ToString();
            if (itemData != null)
            {
                this.m_aiStatus = this.m_aiStatus + " Weapon:" + itemData.m_shared.m_name;
            }
            Vector3 point = this.m_targetCreature ? this.m_targetCreature.transform.position : this.m_targetStatic.transform.position;
            base.RandomMovementArroundPoint(dt, point, this.m_randomMoveRange, base.IsAlerted());
            return;
        }
        if ((!(this.m_targetStatic == null) || !(this.m_targetCreature == null)) && itemData != null)
        {
            if (itemData.m_shared.m_aiTargetType == ItemDrop.ItemData.AiTarget.Enemy)
            {
                if (this.m_targetStatic)
                {
                    Vector3 vector = this.m_targetStatic.FindClosestPoint(base.transform.position);
                    if (Vector3.Distance(vector, base.transform.position) >= itemData.m_shared.m_aiAttackRange || !base.CanSeeTarget(this.m_targetStatic))
                    {
                        this.m_aiStatus = "Move to static target";
                        base.MoveTo(dt, vector, 0f, base.IsAlerted());
                        return;
                    }
                    base.LookAt(this.m_targetStatic.GetCenter());
                    if (base.IsLookingAt(this.m_targetStatic.GetCenter(), itemData.m_shared.m_aiAttackMaxAngle) && flag3)
                    {
                        this.m_aiStatus = "Attacking piece";
                        this.DoAttack(null, false);
                        return;
                    }
                    base.StopMoving();
                    return;
                }
                else if (this.m_targetCreature)
                {
                    if (flag || flag2 || (this.HuntPlayer() && this.m_targetCreature.IsPlayer()))
                    {
                        this.m_beenAtLastPos      = false;
                        this.m_lastKnownTargetPos = this.m_targetCreature.transform.position;
                        float num  = Vector3.Distance(this.m_lastKnownTargetPos, base.transform.position) - this.m_targetCreature.GetRadius();
                        float num2 = this.m_alertRange * this.m_targetCreature.GetStealthFactor();
                        if ((flag2 && num < num2) || this.HuntPlayer())
                        {
                            this.SetAlerted(true);
                        }
                        bool flag4 = num < itemData.m_shared.m_aiAttackRange;
                        if (!flag4 || !flag2 || itemData.m_shared.m_aiAttackRangeMin < 0f || !base.IsAlerted())
                        {
                            this.m_aiStatus = "Move closer";
                            Vector3 velocity = this.m_targetCreature.GetVelocity();
                            Vector3 vector2  = velocity * this.m_interceptTime;
                            Vector3 vector3  = this.m_lastKnownTargetPos;
                            if (num > vector2.magnitude / 4f)
                            {
                                vector3 += velocity * this.m_interceptTime;
                            }
                            if (base.MoveTo(dt, vector3, 0f, base.IsAlerted()))
                            {
                                flag4 = true;
                            }
                        }
                        else
                        {
                            base.StopMoving();
                        }
                        if (flag4 && flag2 && base.IsAlerted())
                        {
                            this.m_aiStatus = "In attack range";
                            base.LookAt(this.m_targetCreature.GetTopPoint());
                            if (flag3 && base.IsLookingAt(this.m_lastKnownTargetPos, itemData.m_shared.m_aiAttackMaxAngle))
                            {
                                this.m_aiStatus = "Attacking creature";
                                this.DoAttack(this.m_targetCreature, false);
                                return;
                            }
                        }
                    }
                    else
                    {
                        this.m_aiStatus = "Searching for target";
                        if (this.m_beenAtLastPos)
                        {
                            base.RandomMovement(dt, this.m_lastKnownTargetPos);
                            return;
                        }
                        if (base.MoveTo(dt, this.m_lastKnownTargetPos, 0f, base.IsAlerted()))
                        {
                            this.m_beenAtLastPos = true;
                            return;
                        }
                    }
                }
            }
            else if (itemData.m_shared.m_aiTargetType == ItemDrop.ItemData.AiTarget.FriendHurt || itemData.m_shared.m_aiTargetType == ItemDrop.ItemData.AiTarget.Friend)
            {
                this.m_aiStatus = "Helping friend";
                Character character = (itemData.m_shared.m_aiTargetType == ItemDrop.ItemData.AiTarget.FriendHurt) ? base.HaveHurtFriendInRange(this.m_viewRange) : base.HaveFriendInRange(this.m_viewRange);
                if (character)
                {
                    if (Vector3.Distance(character.transform.position, base.transform.position) >= itemData.m_shared.m_aiAttackRange)
                    {
                        base.MoveTo(dt, character.transform.position, 0f, base.IsAlerted());
                        return;
                    }
                    if (flag3)
                    {
                        base.StopMoving();
                        base.LookAt(character.transform.position);
                        this.DoAttack(character, true);
                        return;
                    }
                    base.RandomMovement(dt, character.transform.position);
                    return;
                }
                else
                {
                    base.RandomMovement(dt, base.transform.position);
                }
            }
            return;
        }
        if (this.m_follow)
        {
            base.Follow(this.m_follow, dt);
            this.m_aiStatus = "Follow";
            return;
        }
        this.m_aiStatus = string.Concat(new object[]
        {
            "Random movement (weapon: ",
            (itemData != null) ? itemData.m_shared.m_name : "none",
            ") (targetpiece: ",
            this.m_targetStatic,
            ") (target: ",
            this.m_targetCreature ? this.m_targetCreature.gameObject.name : "none",
            ")"
        });
        base.IdleMovement(dt);
    }
示例#11
0
            static void Postfix(CookingStation __instance, ZNetView ___m_nview)
            {
                if (!modEnabled.Value || !___m_nview.IsValid() || !___m_nview.IsOwner() || !EffectArea.IsPointInsideArea(__instance.transform.position, EffectArea.Type.Burning, 0.25f))
                {
                    return;
                }
                for (int i = 0; i < __instance.m_slots.Length; i++)
                {
                    string itemName = ___m_nview.GetZDO().GetString("slot" + i, "");

                    float num = ___m_nview.GetZDO().GetFloat("slot" + i, 0f);
                    if (itemName != "" && itemName != __instance.m_overCookedItem.name && itemName != null)
                    {
                        CookingStation.ItemConversion itemConversion = Traverse.Create(__instance).Method("GetItemConversion", new object[] { itemName }).GetValue <CookingStation.ItemConversion>();
                        if (num > itemConversion.m_cookTime && itemName == itemConversion.m_to.name)
                        {
                            if (autoPop.Value)
                            {
                                Traverse.Create(__instance).Method("SpawnItem", new object[] { itemName }).GetValue();
                                ___m_nview.GetZDO().Set("slot" + i, "");
                                ___m_nview.GetZDO().Set("slot" + i, 0f);
                                ___m_nview.InvokeRPC(ZNetView.Everybody, "SetSlotVisual", new object[] { i, "" });
                            }
                            else if (preventBurning.Value)
                            {
                                ___m_nview.GetZDO().Set("slot" + i, itemConversion.m_cookTime);
                            }
                        }
                    }
                }
            }
示例#12
0
        protected static IEnumerator GetRandomPointInBiome(Heightmap.Biome biome, AdventureSaveData saveData, Action <bool, Vector3, Vector3> onComplete)
        {
            const int maxRangeIncreases = 10;
            const int maxPointsInRange  = 15;

            MerchantPanel.ShowInputBlocker(true);

            var rangeTries  = 0;
            var radiusRange = GetTreasureMapSpawnRadiusRange(biome, saveData);

            while (rangeTries < maxRangeIncreases)
            {
                rangeTries++;

                var tries = 0;
                while (tries < maxPointsInRange)
                {
                    tries++;

                    var randomPoint = UnityEngine.Random.insideUnitCircle;
                    var mag         = randomPoint.magnitude;
                    var normalized  = randomPoint.normalized;
                    var actualMag   = Mathf.Lerp(radiusRange.Item1, radiusRange.Item2, mag);
                    randomPoint = normalized * actualMag;
                    var spawnPoint = new Vector3(randomPoint.x, 0, randomPoint.y);

                    var zoneId = ZoneSystem.instance.GetZone(spawnPoint);
                    while (!ZoneSystem.instance.SpawnZone(zoneId, ZoneSystem.SpawnMode.Client, out _))
                    {
                        EpicLoot.LogWarning($"Spawning Zone ({zoneId})...");
                        yield return(null);
                    }

                    ZoneSystem.instance.GetGroundData(ref spawnPoint, out var normal, out var foundBiome, out _, out _);
                    var groundHeight = spawnPoint.y;

                    EpicLoot.Log($"Checking biome at ({randomPoint}): {foundBiome} (try {tries})");
                    if (foundBiome != biome)
                    {
                        // Wrong biome
                        continue;
                    }

                    var solidHeight      = ZoneSystem.instance.GetSolidHeight(spawnPoint);
                    var offsetFromGround = Math.Abs(solidHeight - groundHeight);
                    if (offsetFromGround > 5)
                    {
                        // Don't place too high off the ground (on top of tree or something?
                        EpicLoot.Log($"Spawn Point rejected: too high off of ground (groundHeight:{groundHeight}, solidHeight:{solidHeight})");
                        continue;
                    }

                    // But also don't place inside rocks
                    spawnPoint.y = solidHeight;

                    var placedNearPlayerBase = EffectArea.IsPointInsideArea(spawnPoint, EffectArea.Type.PlayerBase, AdventureDataManager.Config.TreasureMap.MinimapAreaRadius);
                    if (placedNearPlayerBase)
                    {
                        // Don't place near player base
                        EpicLoot.Log("Spawn Point rejected: too close to player base");
                        continue;
                    }

                    EpicLoot.Log($"Wards: {PrivateArea.m_allAreas.Count}");
                    var tooCloseToWard = PrivateArea.m_allAreas.Any(x => x.IsInside(spawnPoint, AdventureDataManager.Config.TreasureMap.MinimapAreaRadius));
                    if (tooCloseToWard)
                    {
                        EpicLoot.Log("Spawn Point rejected: too close to player ward");
                        continue;
                    }

                    var waterLevel = ZoneSystem.instance.m_waterLevel;
                    if (waterLevel > groundHeight + 1.0f)
                    {
                        // Too deep, try again
                        EpicLoot.Log($"Spawn Point rejected: too deep underwater (waterLevel:{waterLevel}, groundHeight:{groundHeight})");
                        continue;
                    }

                    EpicLoot.Log($"Success! (ground={groundHeight} water={waterLevel} placed={spawnPoint.y})");

                    onComplete?.Invoke(true, spawnPoint, normal);
                    MerchantPanel.ShowInputBlocker(false);
                    yield break;
                }

                radiusRange = new Tuple <float, float>(radiusRange.Item1 + 500, radiusRange.Item2 + 500);
            }

            onComplete?.Invoke(false, new Vector3(), new Vector3());
            MerchantPanel.ShowInputBlocker(false);
        }
示例#13
0
    // Token: 0x06000BD1 RID: 3025 RVA: 0x00054504 File Offset: 0x00052704
    private bool IsSpawnPointGood(SpawnSystem.SpawnData spawn, ref Vector3 spawnPoint)
    {
        Vector3 vector;

        Heightmap.Biome     biome;
        Heightmap.BiomeArea biomeArea;
        Heightmap           heightmap;

        ZoneSystem.instance.GetGroundData(ref spawnPoint, out vector, out biome, out biomeArea, out heightmap);
        if ((spawn.m_biome & biome) == Heightmap.Biome.None)
        {
            return(false);
        }
        if ((spawn.m_biomeArea & biomeArea) == (Heightmap.BiomeArea) 0)
        {
            return(false);
        }
        if (ZoneSystem.instance.IsBlocked(spawnPoint))
        {
            return(false);
        }
        float num = spawnPoint.y - ZoneSystem.instance.m_waterLevel;

        if (num < spawn.m_minAltitude || num > spawn.m_maxAltitude)
        {
            return(false);
        }
        float num2 = Mathf.Cos(0.017453292f * spawn.m_maxTilt);
        float num3 = Mathf.Cos(0.017453292f * spawn.m_minTilt);

        if (vector.y < num2 || vector.y > num3)
        {
            return(false);
        }
        float range = (spawn.m_spawnRadiusMin > 0f) ? spawn.m_spawnRadiusMin : 40f;

        if (Player.IsPlayerInRange(spawnPoint, range))
        {
            return(false);
        }
        if (EffectArea.IsPointInsideArea(spawnPoint, EffectArea.Type.PlayerBase, 0f))
        {
            return(false);
        }
        if (!spawn.m_inForest || !spawn.m_outsideForest)
        {
            bool flag = WorldGenerator.InForest(spawnPoint);
            if (!spawn.m_inForest && flag)
            {
                return(false);
            }
            if (!spawn.m_outsideForest && !flag)
            {
                return(false);
            }
        }
        if (spawn.m_minOceanDepth != spawn.m_maxOceanDepth && heightmap != null)
        {
            float oceanDepth = heightmap.GetOceanDepth(spawnPoint);
            if (oceanDepth < spawn.m_minOceanDepth || oceanDepth > spawn.m_maxOceanDepth)
            {
                return(false);
            }
        }
        return(true);
    }
示例#14
0
            private static Boolean Prefix(Player __instance, bool flashGuardStone)
            {
                Player PlayerInstance = __instance;

                if (PlayerInstance == null)
                {
                    return(true);
                }

                if (!Settings.isEnabled("AdvancedBuildingMode") || !__instance.InPlaceMode())
                {
                    return(true);
                }

                KeyCode enter = Settings.getHotkey("enterAdvancedBuildingMode");
                KeyCode exit  = Settings.getHotkey("exitAdvancedBuildingMode");

                // Error Handling/Detection for Hoe & Terrain Tool
                if (PlayerInstance.m_buildPieces != null)
                {
                    GameObject selectedPrefab = PlayerInstance.m_buildPieces.GetSelectedPrefab();
                    if (selectedPrefab == null || IsHoeOrTerrainTool(selectedPrefab))
                    {
                        return(true);
                    }
                }

                // Prevent cross usage of ABM & ABE
                if (AdvancedEditingMode.isInAEM)
                {
                    return(true);
                }


                // Delayed function stop to place the object at the right location (if we would immediatly stop, it would be placed at cursor location)
                if (DelayedStop)
                {
                    isInABM      = false;
                    DelayedStop  = false;
                    BlockRefresh = false;
                    return(true);
                }

                // Error Handling and removal of left over placement marker
                if (!PlayerInstance.InPlaceMode() || PlayerInstance.m_placementGhost == null || PlayerInstance.m_buildPieces == null)
                {
                    DelayedStop  = false;
                    BlockRefresh = false;
                    if (PlayerInstance.m_placementMarkerInstance != null)
                    {
                        PlayerInstance.m_placementMarkerInstance.SetActive(false);
                    }
                    return(true);
                }


                float rX = 0;
                float rZ = 0;
                float rY = 0;

                if (Input.GetKeyDown(enter))
                {
                    isInABM      = true;
                    DelayedStop  = false;
                    BlockRefresh = true;
                }
                if (Input.GetKeyDown(exit))
                {
                    DelayedStop = true;
                    PlayerInstance.m_placeRotation = 0;
                }

                float distance       = 2;
                float scrollDistance = 2;

                // TODO ADD INCREASE / DECREASE HOTKEYS
                // TODO ADD HOTKEY TO SAVE / LOAD ROTATION

                // CONTROL PRESSED
                if (Input.GetKeyDown(KeyCode.LeftControl))
                {
                    controlFlag = true;
                }
                if (Input.GetKeyUp(KeyCode.LeftControl))
                {
                    controlFlag = false;
                }


                // Detect hotkey presses for hotbar to reduce potential issues
                if (Input.GetKeyDown(KeyCode.Alpha1))
                {
                    DelayedStop = true;
                }
                if (Input.GetKeyDown(KeyCode.Alpha2))
                {
                    DelayedStop = true;
                }
                if (Input.GetKeyDown(KeyCode.Alpha3))
                {
                    DelayedStop = true;
                }
                if (Input.GetKeyDown(KeyCode.Alpha4))
                {
                    DelayedStop = true;
                }
                if (Input.GetKeyDown(KeyCode.Alpha5))
                {
                    DelayedStop = true;
                }
                if (Input.GetKeyDown(KeyCode.Alpha6))
                {
                    DelayedStop = true;
                }
                if (Input.GetKeyDown(KeyCode.Alpha7))
                {
                    DelayedStop = true;
                }
                if (Input.GetKeyDown(KeyCode.Alpha8))
                {
                    DelayedStop = true;
                }
                if (Input.GetKeyDown(KeyCode.Alpha9))
                {
                    DelayedStop = true;
                }
                if (Input.GetKeyDown(KeyCode.Alpha0))
                {
                    DelayedStop = true;
                }


                // SHIFT PRESSED
                if (Input.GetKeyDown(KeyCode.LeftShift))
                {
                    shiftFlag = true;
                }
                if (Input.GetKeyUp(KeyCode.LeftShift))
                {
                    shiftFlag = false;
                }
                if (shiftFlag)
                {
                    distance = 2 * 3; scrollDistance = 2 * 3;
                }
                else
                {
                    distance = 2; scrollDistance = 2;
                }

                // LEFT ALT PRESSED
                if (Input.GetKeyDown(KeyCode.LeftAlt))
                {
                    altFlag = true;
                }
                if (Input.GetKeyUp(KeyCode.LeftAlt))
                {
                    altFlag = false;
                }


                Piece component = PlayerInstance.m_placementGhost.GetComponent <Piece>();

                // Maximum distance between player and placed piece
                if (Vector3.Distance(__instance.transform.position, component.transform.position) > 25)
                {
                    DelayedStop = true;
                }

                if (Input.GetAxis("Mouse ScrollWheel") > 0f)
                {
                    Quaternion rotation;
                    if (controlFlag)
                    {
                        rX++;
                        rotation = Quaternion.Euler(component.transform.eulerAngles.x + (scrollDistance * (float)rX), component.transform.eulerAngles.y, component.transform.eulerAngles.z); // forward to backwards
                    }
                    else
                    {
                        if (altFlag)
                        {
                            rZ++;
                            rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y, component.transform.eulerAngles.z + (scrollDistance * (float)rZ)); // diagonal
                        }
                        else
                        {
                            rY++;
                            rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y + (scrollDistance * (float)rY), component.transform.eulerAngles.z); // left<->right
                        }
                    }
                    component.transform.rotation = rotation;
                }
                if (Input.GetAxis("Mouse ScrollWheel") < 0f)
                {
                    Quaternion rotation;
                    if (controlFlag)
                    {
                        rX--;
                        rotation = Quaternion.Euler(component.transform.eulerAngles.x + (scrollDistance * (float)rX), component.transform.eulerAngles.y, component.transform.eulerAngles.z); // forward to backwards
                    }
                    else
                    {
                        if (altFlag)
                        {
                            rZ--;
                            rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y, component.transform.eulerAngles.z + (scrollDistance * (float)rZ)); // diagonal
                        }
                        else
                        {
                            rY--;
                            rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y + (scrollDistance * (float)rY), component.transform.eulerAngles.z); // left<->right
                        }
                    }

                    component.transform.rotation = rotation;
                }


                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    if (controlFlag)
                    {
                        component.transform.Translate(Vector3.up * distance * Time.deltaTime);
                    }
                    else
                    {
                        component.transform.Translate(Vector3.forward * distance * Time.deltaTime);
                    }
                }
                if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    if (controlFlag)
                    {
                        component.transform.Translate(Vector3.down * distance * Time.deltaTime);
                    }
                    else
                    {
                        component.transform.Translate(Vector3.back * distance * Time.deltaTime);
                    }
                }
                if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    component.transform.Translate(Vector3.left * distance * Time.deltaTime);
                }
                if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    component.transform.Translate(Vector3.right * distance * Time.deltaTime);
                }


                bool water = component.m_waterPiece || component.m_noInWater;

                PlayerInstance.m_placementStatus = 0;

                if (component.m_groundOnly || component.m_groundPiece || component.m_cultivatedGroundOnly)
                {
                    PlayerInstance.m_placementMarkerInstance.SetActive(false);
                }

                StationExtension component2 = component.GetComponent <StationExtension>();

                if (component2 != null)
                {
                    CraftingStation craftingStation = component2.FindClosestStationInRange(component.transform.position);
                    if (craftingStation)
                    {
                        component2.StartConnectionEffect(craftingStation);
                    }
                    else
                    {
                        component2.StopConnectionEffect();
                        PlayerInstance.m_placementStatus = Player.PlacementStatus.ExtensionMissingStation; // Missing Station
                    }
                    if (component2.OtherExtensionInRange(component.m_spaceRequirement))
                    {
                        PlayerInstance.m_placementStatus = Player.PlacementStatus.MoreSpace; // More Space
                    }
                }

                if (component.m_onlyInTeleportArea && !EffectArea.IsPointInsideArea(component.transform.position, EffectArea.Type.Teleport, 0f))
                {
                    PlayerInstance.m_placementStatus = Player.PlacementStatus.NoTeleportArea;
                }
                if (!component.m_allowedInDungeons && (component.transform.position.y > 3000f))
                {
                    PlayerInstance.m_placementStatus = Player.PlacementStatus.NotInDungeon;
                }
                if (Location.IsInsideNoBuildLocation(PlayerInstance.m_placementGhost.transform.position))
                {
                    PlayerInstance.m_placementStatus = Player.PlacementStatus.NoBuildZone;
                }
                float radius = component.GetComponent <PrivateArea>() ? component.GetComponent <PrivateArea>().m_radius : 0f;

                if (!PrivateArea.CheckAccess(PlayerInstance.m_placementGhost.transform.position, radius, flashGuardStone))
                {
                    PlayerInstance.m_placementStatus = Player.PlacementStatus.PrivateZone;
                }

                if (PlayerInstance.m_placementStatus != 0)
                {
                    component.SetInvalidPlacementHeightlight(true);
                }
                else
                {
                    component.SetInvalidPlacementHeightlight(false);
                }

                if (Input.GetKeyDown(KeyCode.Mouse0))
                {
                    // Stop with the next iteration of the function and place the piece
                    DelayedStop = true;
                }



                return(!BlockRefresh);
            }
示例#15
0
            // almost copy of original UpdatePlacementGhost with modified calculation of Quaternion quaternion = Quaternion.Euler(rotation);
            // need to be re-calculated in Postfix for correct work of auto-attachment of placementGhost after change rotation
            private static void UpdatePlacementGhost(Player __instance, bool flashGuardStone)
            {
                if ((UnityEngine.Object)__instance.m_placementGhost == (UnityEngine.Object)null)
                {
                    if (!(bool)(UnityEngine.Object)__instance.m_placementMarkerInstance)
                    {
                        return;
                    }
                    __instance.m_placementMarkerInstance.SetActive(false);
                }
                else
                {
                    bool      flag       = ZInput.GetButton("AltPlace") || ZInput.GetButton("JoyAltPlace");
                    Piece     component1 = __instance.m_placementGhost.GetComponent <Piece>();
                    bool      water      = component1.m_waterPiece || component1.m_noInWater;
                    Vector3   point;
                    Vector3   normal;
                    Piece     piece;
                    Heightmap heightmap;
                    Collider  waterSurface;
                    if (__instance.PieceRayTest(out point, out normal, out piece, out heightmap, out waterSurface, water))
                    {
                        __instance.m_placementStatus = Player.PlacementStatus.Valid;
                        if ((UnityEngine.Object)__instance.m_placementMarkerInstance == (UnityEngine.Object)null)
                        {
                            __instance.m_placementMarkerInstance =
                                UnityEngine.Object.Instantiate <GameObject>(__instance.m_placeMarker, point,
                                                                            Quaternion.identity);
                        }
                        __instance.m_placementMarkerInstance.SetActive(true);
                        __instance.m_placementMarkerInstance.transform.position = point;
                        __instance.m_placementMarkerInstance.transform.rotation = Quaternion.LookRotation(normal);
                        if (component1.m_groundOnly || component1.m_groundPiece || component1.m_cultivatedGroundOnly)
                        {
                            __instance.m_placementMarkerInstance.SetActive(false);
                        }
                        WearNTear wearNtear = (UnityEngine.Object)piece != (UnityEngine.Object)null
                            ? piece.GetComponent <WearNTear>()
                            : (WearNTear)null;
                        StationExtension component2 = component1.GetComponent <StationExtension>();
                        if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
                        {
                            CraftingStation closestStationInRange = component2.FindClosestStationInRange(point);
                            if ((bool)(UnityEngine.Object)closestStationInRange)
                            {
                                component2.StartConnectionEffect(closestStationInRange);
                            }
                            else
                            {
                                component2.StopConnectionEffect();
                                __instance.m_placementStatus = Player.PlacementStatus.ExtensionMissingStation;
                            }

                            if (component2.OtherExtensionInRange(component1.m_spaceRequirement))
                            {
                                __instance.m_placementStatus = Player.PlacementStatus.MoreSpace;
                            }
                        }

                        if ((bool)(UnityEngine.Object)wearNtear && !wearNtear.m_supports)
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.Invalid;
                        }
                        if (component1.m_waterPiece && (UnityEngine.Object)waterSurface == (UnityEngine.Object)null &&
                            !flag)
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.Invalid;
                        }
                        if (component1.m_noInWater && (UnityEngine.Object)waterSurface != (UnityEngine.Object)null)
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.Invalid;
                        }
                        if (component1.m_groundPiece && (UnityEngine.Object)heightmap == (UnityEngine.Object)null)
                        {
                            __instance.m_placementGhost.SetActive(false);
                            __instance.m_placementStatus = Player.PlacementStatus.Invalid;
                            return;
                        }

                        if (component1.m_groundOnly && (UnityEngine.Object)heightmap == (UnityEngine.Object)null)
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.Invalid;
                        }
                        if (component1.m_cultivatedGroundOnly &&
                            ((UnityEngine.Object)heightmap == (UnityEngine.Object)null ||
                             !heightmap.IsCultivated(point)))
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.NeedCultivated;
                        }
                        if (component1.m_notOnWood && (bool)(UnityEngine.Object)piece &&
                            (bool)(UnityEngine.Object)wearNtear &&
                            (wearNtear.m_materialType == WearNTear.MaterialType.Wood ||
                             wearNtear.m_materialType == WearNTear.MaterialType.HardWood))
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.Invalid;
                        }
                        if (component1.m_notOnTiltingSurface && (double)normal.y < 0.800000011920929)
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.Invalid;
                        }
                        if (component1.m_inCeilingOnly && (double)normal.y > -0.5)
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.Invalid;
                        }
                        if (component1.m_notOnFloor && (double)normal.y > 0.100000001490116)
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.Invalid;
                        }
                        if (component1.m_onlyInTeleportArea &&
                            !(bool)(UnityEngine.Object)EffectArea.IsPointInsideArea(point, EffectArea.Type.Teleport,
                                                                                    0.0f))
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.NoTeleportArea;
                        }
                        if (!component1.m_allowedInDungeons && __instance.InInterior())
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.NotInDungeon;
                        }
                        if ((bool)(UnityEngine.Object)heightmap)
                        {
                            normal = Vector3.up;
                        }
                        __instance.m_placementGhost.SetActive(true);

                        var rotation = PlayersData.ContainsKey(__instance)
                            ? PlayersData[__instance].PlaceRotation
                            : __instance.m_placeRotation * 22.5f * Vector3.up;

                        Quaternion quaternion = Quaternion.Euler(rotation);

                        if ((component1.m_groundPiece || component1.m_clipGround) &&
                            (bool)(UnityEngine.Object)heightmap || component1.m_clipEverything)
                        {
                            if ((bool)(UnityEngine.Object)__instance.m_buildPieces.GetSelectedPrefab()
                                .GetComponent <TerrainModifier>() && component1.m_allowAltGroundPlacement &&
                                (component1.m_groundPiece && !ZInput.GetButton("AltPlace")) &&
                                !ZInput.GetButton("JoyAltPlace"))
                            {
                                float groundHeight = ZoneSystem.instance.GetGroundHeight(__instance.transform.position);
                                point.y = groundHeight;
                            }

                            __instance.m_placementGhost.transform.position = point;
                            __instance.m_placementGhost.transform.rotation = quaternion;
                        }
                        else
                        {
                            Collider[] componentsInChildren = __instance.m_placementGhost.GetComponentsInChildren <Collider>();
                            if (componentsInChildren.Length != 0)
                            {
                                __instance.m_placementGhost.transform.position = point + normal * 50f;
                                __instance.m_placementGhost.transform.rotation = quaternion;
                                Vector3 vector3_1 = Vector3.zero;
                                float   num1      = 999999f;
                                foreach (Collider collider in componentsInChildren)
                                {
                                    if (!collider.isTrigger && collider.enabled)
                                    {
                                        MeshCollider meshCollider = collider as MeshCollider;
                                        if (!((UnityEngine.Object)meshCollider != (UnityEngine.Object)null) ||
                                            meshCollider.convex)
                                        {
                                            Vector3 a    = collider.ClosestPoint(point);
                                            float   num2 = Vector3.Distance(a, point);
                                            if ((double)num2 < (double)num1)
                                            {
                                                vector3_1 = a;
                                                num1      = num2;
                                            }
                                        }
                                    }
                                }

                                Vector3 vector3_2 = __instance.m_placementGhost.transform.position - vector3_1;
                                if (component1.m_waterPiece)
                                {
                                    vector3_2.y = 3f;
                                }
                                __instance.m_placementGhost.transform.position = point + vector3_2;
                                __instance.m_placementGhost.transform.rotation = quaternion;
                            }
                        }

                        if (!flag)
                        {
                            __instance.m_tempPieces.Clear();
                            Transform a;
                            Transform b;
                            if (__instance.FindClosestSnapPoints(__instance.m_placementGhost.transform, 0.5f, out a, out b,
                                                                 __instance.m_tempPieces))
                            {
                                Vector3 position = b.parent.position;
                                Vector3 p        = b.position - (a.position - __instance.m_placementGhost.transform.position);
                                if (!__instance.IsOverlapingOtherPiece(p, __instance.m_placementGhost.transform.rotation, __instance.m_placementGhost.name, __instance.m_tempPieces, component1.m_allowRotatedOverlap))
                                {
                                    __instance.m_placementGhost.transform.position = p;
                                }
                            }
                        }

                        if (Location.IsInsideNoBuildLocation(__instance.m_placementGhost.transform.position))
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.NoBuildZone;
                        }
                        if (!PrivateArea.CheckAccess(__instance.m_placementGhost.transform.position,
                                                     (bool)(UnityEngine.Object)component1.GetComponent <PrivateArea>()
                                ? component1.GetComponent <PrivateArea>().m_radius
                                : 0.0f, flashGuardStone))
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.PrivateZone;
                        }
                        if (__instance.CheckPlacementGhostVSPlayers())
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.BlockedbyPlayer;
                        }
                        if (component1.m_onlyInBiome != Heightmap.Biome.None &&
                            (Heightmap.FindBiome(__instance.m_placementGhost.transform.position) &
                             component1.m_onlyInBiome) == Heightmap.Biome.None)
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.WrongBiome;
                        }
                        if (component1.m_noClipping && __instance.TestGhostClipping(__instance.m_placementGhost, 0.2f))
                        {
                            __instance.m_placementStatus = Player.PlacementStatus.Invalid;
                        }
                    }
                    else
                    {
                        if ((bool)(UnityEngine.Object)__instance.m_placementMarkerInstance)
                        {
                            __instance.m_placementMarkerInstance.SetActive(false);
                        }
                        __instance.m_placementGhost.SetActive(false);
                        __instance.m_placementStatus = Player.PlacementStatus.Invalid;
                    }

                    __instance.SetPlacementGhostValid(__instance.m_placementStatus == Player.PlacementStatus.Valid);
                }
            }
示例#16
0
            private static Boolean Prefix(ref Player __instance, ref Int32 ___m_placementStatus, ref GameObject ___m_placementGhost, ref GameObject ___m_placementMarkerInstance, ref int ___m_placeRotation)
            {
                if (Conf.AdvancedBuildingMode != null)
                {
                    return(true);
                }

                KeyCode enter = Conf.AdvancedBuildingMode.EnterAdvancedBuildingMode;
                KeyCode exit  = Conf.AdvancedBuildingMode.ExitAdvancedBuildingMode;

                // Error Handling and removal of left over placement marker
                if (!__instance.InPlaceMode() || ___m_placementGhost == null)
                {
                    DelayedStop  = false;
                    BlockRefresh = false;
                    ___m_placementMarkerInstance.SetActive(false);
                    return(true);
                }

                // Delayed function stop to place the object at the right location (if we would immediatly stop, it would be placed at cursor location)
                if (DelayedStop)
                {
                    DelayedStop  = false;
                    BlockRefresh = false;
                    return(true);
                }

                float rX = 0;
                float rZ = 0;
                float rY = 0;

                Piece component = ___m_placementGhost.GetComponent <Piece>();

                if (Input.GetKeyDown(enter))
                {
                    BlockRefresh = true;
                }
                if (Input.GetKeyDown(exit))
                {
                    BlockRefresh       = false;
                    ___m_placeRotation = 0;
                }

                float distance       = 2;
                float scrollDistance = 2;

                // TODO ADD INCREASE / DECREASE HOTKEYS
                // TODO ADD HOTKEY TO SAVE / LOAD ROTATION

                if (Input.GetKeyDown(KeyCode.LeftControl))
                {
                    controlFlag = true;
                }
                if (Input.GetKeyUp(KeyCode.LeftControl))
                {
                    controlFlag = false;
                }

                if (Input.GetKeyDown(KeyCode.LeftShift))
                {
                    shiftFlag = true;
                }
                if (Input.GetKeyUp(KeyCode.LeftShift))
                {
                    shiftFlag = false;
                }
                if (shiftFlag)
                {
                    distance = 6; scrollDistance = 6;
                }
                else
                {
                    distance = 2; scrollDistance = 2;
                }

                if (Input.GetKeyDown(KeyCode.LeftAlt))
                {
                    altFlag = true;
                }
                if (Input.GetKeyUp(KeyCode.LeftAlt))
                {
                    altFlag = false;
                }

                if (Input.GetAxis("Mouse ScrollWheel") > 0f)
                {
                    Quaternion rotation;
                    if (controlFlag)
                    {
                        rX++;
                        rotation = Quaternion.Euler(component.transform.eulerAngles.x + (scrollDistance * (float)rX), component.transform.eulerAngles.y, component.transform.eulerAngles.z); // forward to backwards
                    }
                    else
                    {
                        if (altFlag)
                        {
                            rZ++;
                            rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y, component.transform.eulerAngles.z + (scrollDistance * (float)rZ)); // diagonal
                        }
                        else
                        {
                            rY++;
                            rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y + (scrollDistance * (float)rY), component.transform.eulerAngles.z); // left<->right
                        }
                    }
                    component.transform.rotation = rotation;
                }
                if (Input.GetAxis("Mouse ScrollWheel") < 0f)
                {
                    Quaternion rotation;
                    if (controlFlag)
                    {
                        rX--;
                        rotation = Quaternion.Euler(component.transform.eulerAngles.x + (scrollDistance * (float)rX), component.transform.eulerAngles.y, component.transform.eulerAngles.z); // forward to backwards
                    }
                    else
                    {
                        if (altFlag)
                        {
                            rZ--;
                            rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y, component.transform.eulerAngles.z + (scrollDistance * (float)rZ)); // diagonal
                        }
                        else
                        {
                            rY--;
                            rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y + (scrollDistance * (float)rY), component.transform.eulerAngles.z); // left<->right
                        }
                    }

                    component.transform.rotation = rotation;
                }


                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    if (controlFlag)
                    {
                        component.transform.Translate(Vector3.up * distance * Time.deltaTime);
                    }
                    else
                    {
                        component.transform.Translate(Vector3.forward * distance * Time.deltaTime);
                    }
                }
                if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    if (controlFlag)
                    {
                        component.transform.Translate(Vector3.down * distance * Time.deltaTime);
                    }
                    else
                    {
                        component.transform.Translate(Vector3.back * distance * Time.deltaTime);
                    }
                }
                if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    component.transform.Translate(Vector3.left * distance * Time.deltaTime);
                }
                if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    component.transform.Translate(Vector3.right * distance * Time.deltaTime);
                }


                // ToDo, add a custom additional downwards raycast from the position of the component to the ground to add the rest of the placement restrictions

                bool water = component.m_waterPiece || component.m_noInWater;

                ___m_placementStatus = 0; // VALID

                if (component.m_groundOnly || component.m_groundPiece || component.m_cultivatedGroundOnly)
                {
                    ___m_placementMarkerInstance.SetActive(false);
                }

                StationExtension component2 = component.GetComponent <StationExtension>();

                if (component2 != null)
                {
                    CraftingStation craftingStation = component2.FindClosestStationInRange(component.transform.position);
                    if (craftingStation)
                    {
                        component2.StartConnectionEffect(craftingStation);
                    }
                    else
                    {
                        component2.StopConnectionEffect();
                        ___m_placementStatus = 7; // Missing Station
                    }
                    if (component2.OtherExtensionInRange(component.m_spaceRequirement))
                    {
                        ___m_placementStatus = 5; // More Space
                    }
                }

                if (component.m_onlyInTeleportArea && !EffectArea.IsPointInsideArea(component.transform.position, EffectArea.Type.Teleport, 0f))
                {
                    ___m_placementStatus = 6;
                }
                if (!component.m_allowedInDungeons && (component.transform.position.y > 3000f))
                {
                    ___m_placementStatus = 10;
                }
                if (Location.IsInsideNoBuildLocation(___m_placementGhost.transform.position))
                {
                    ___m_placementStatus = 3;
                }
                float radius = component.GetComponent <PrivateArea>() ? component.GetComponent <PrivateArea>().m_radius : 0f;

                if (!PrivateArea.CheckAccess(___m_placementGhost.transform.position, radius, true))
                {
                    ___m_placementStatus = 4;
                }

                if (___m_placementStatus != 0)
                {
                    component.SetInvalidPlacementHeightlight(true);
                }
                else
                {
                    component.SetInvalidPlacementHeightlight(false);
                }

                if (Input.GetKeyDown(KeyCode.Mouse0))
                {
                    // Stop with the next iteration of the function and place the piece
                    DelayedStop = true;
                }

                return(!BlockRefresh);
            }
示例#17
0
 // Token: 0x06000CCB RID: 3275 RVA: 0x0005BA37 File Offset: 0x00059C37
 private bool IsFireLit()
 {
     return(EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.Burning, 0.25f));
 }
示例#18
0
 // Token: 0x060006C9 RID: 1737 RVA: 0x000383BC File Offset: 0x000365BC
 private bool IsInsideBase()
 {
     return(base.transform.position.y > ZoneSystem.instance.m_waterLevel + -2f && EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.PlayerBase, 0f));
 }
            private static void Postfix(Player __instance)
            {
                if (Settings.isEnabled("AdvancedEditingMode"))
                {
                    if (isInAEM && __instance.InPlaceMode())
                    {
                        DelayedStop = true;
                        HitPiece.transform.position = InitialPosition;
                        HitPiece.transform.rotation = InitialRotation;
                    }

                    if (Input.GetKeyDown(Settings.getHotkey("enterAdvancedEditingMode")) && !isInAEM && !__instance.InPlaceMode())
                    {
                        if (!AdvancedBuildingMode.isInABM)
                        {
                            int       layerMask       = __instance.m_placeRayMask;
                            Character PlayerCharacter = Helper.getPlayerCharacter();

                            if (Physics.Raycast(
                                    GameCamera.instance.transform.position,
                                    GameCamera.instance.transform.forward,
                                    out raycastHit, 50f, layerMask
                                    ) &&
                                raycastHit.collider &&
                                !raycastHit.collider.attachedRigidbody &&
                                Vector3.Distance(PlayerCharacter.m_eye.position, raycastHit.point) < __instance.m_maxPlaceDistance)
                            {
                                HitPoint        = raycastHit.point;
                                HitNormal       = raycastHit.normal;
                                HitPiece        = raycastHit.collider.GetComponentInParent <Piece>();
                                HitObject       = raycastHit.collider.gameObject;
                                HitHeightmap    = raycastHit.collider.GetComponent <Heightmap>();
                                InitialRotation = HitPiece.transform.rotation;
                                InitialPosition = HitPiece.transform.position;
                            }
                            else
                            {
                                HitPoint     = Vector3.zero;
                                HitNormal    = Vector3.zero;
                                HitObject    = null;
                                HitPiece     = null;
                                HitHeightmap = null;
                            }


                            if (HitPiece != null)
                            {
                                Boolean hitValid = true;
                                if (HitPiece.m_onlyInTeleportArea && !EffectArea.IsPointInsideArea(HitPiece.transform.position, EffectArea.Type.Teleport, 0f))
                                {
                                    // Not in Teleport Area
                                    hitValid = false;
                                }
                                if (!HitPiece.m_allowedInDungeons && (HitPiece.transform.position.y > 3000f))
                                {
                                    // Not in dungeon
                                    hitValid = false;
                                }
                                if (Location.IsInsideNoBuildLocation(HitPiece.transform.position))
                                {
                                    // No build zone
                                    hitValid = false;
                                }
                                float radius = HitPiece.GetComponent <PrivateArea>() ? HitPiece.GetComponent <PrivateArea>().m_radius : 0f;
                                if (!PrivateArea.CheckAccess(HitPiece.transform.position, radius, true))
                                {
                                    // private zone
                                    hitValid = false;
                                }
                                // Initialize AEM
                                if (hitValid)
                                {
                                    isInAEM    = true;
                                    HitExsists = true;
                                }
                            }
                        }
                    }

                    try
                    { // check to see if the hit object still exsists
                        if (isInAEM)
                        {
                            exsistenceCheck = HitPiece.transform.position;
                            HitExsists      = true;
                        }
                    }
                    catch (Exception e)
                    {
                        HitExsists = false;
                    }

                    if (DelayedStop || (!HitExsists && isInAEM))
                    {
                        isInAEM         = false;
                        HitPoint        = Vector3.zero;
                        HitNormal       = Vector3.zero;
                        HitObject       = null;
                        HitPiece        = null;
                        HitHeightmap    = null;
                        DelayedStop     = false;
                        InitialRotation = new Quaternion();
                        InitialPosition = new Vector3();
                    }

                    if (isInAEM && !AdvancedBuildingMode.isInABM)
                    {
                        // stop and reset object when entering building mode

                        float rX = 0;
                        float rZ = 0;
                        float rY = 0;

                        if (Input.GetKeyDown(Settings.getHotkey("resetAdvancedEditingMode")))
                        {
                            HitPiece.transform.position = InitialPosition;
                            HitPiece.transform.rotation = InitialRotation;
                        }

                        if (Input.GetKeyDown(Settings.getHotkey("abortAndExitAdvancedEditingMode")))
                        {
                            HitPiece.transform.position = InitialPosition;
                            HitPiece.transform.rotation = InitialRotation;
                            DelayedStop = true;
                        }

                        if (Input.GetKeyDown(Settings.getHotkey("confirmPlacementOfAdvancedEditingMode")))
                        {
                            GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(HitPiece.gameObject, HitPiece.transform.position, HitPiece.transform.rotation);
                            HitPiece.m_placeEffect.Create(HitPiece.transform.position, HitPiece.transform.rotation, gameObject2.transform, 1f);

                            ZNetScene.instance.Destroy(HitPiece.gameObject);

                            DelayedStop = true;
                        }


                        float distance       = 2;
                        float scrollDistance = 2;

                        // TODO ADD INCREASE / DECREASE HOTKEYS
                        // TODO ADD HOTKEY TO SAVE / LOAD ROTATION

                        // CONTROL PRESSED
                        if (Input.GetKeyDown(KeyCode.LeftControl))
                        {
                            controlFlag = true;
                        }
                        if (Input.GetKeyUp(KeyCode.LeftControl))
                        {
                            controlFlag = false;
                        }


                        // SHIFT PRESSED
                        if (Input.GetKeyDown(KeyCode.LeftShift))
                        {
                            shiftFlag = true;
                        }
                        if (Input.GetKeyUp(KeyCode.LeftShift))
                        {
                            shiftFlag = false;
                        }
                        if (shiftFlag)
                        {
                            distance = 2 * 3; scrollDistance = 2 * 3;
                        }
                        else
                        {
                            distance = 2; scrollDistance = 2;
                        }

                        // LEFT ALT PRESSED
                        if (Input.GetKeyDown(KeyCode.LeftAlt))
                        {
                            altFlag = true;
                        }
                        if (Input.GetKeyUp(KeyCode.LeftAlt))
                        {
                            altFlag = false;
                        }


                        Piece component = HitPiece;

                        // Maximum distance between player and placed piece
                        if (Vector3.Distance(__instance.transform.position, component.transform.position) > 25)
                        {
                            HitPiece.transform.position = InitialPosition;
                            HitPiece.transform.rotation = InitialRotation;
                            DelayedStop = true;
                        }

                        if (Input.GetAxis("Mouse ScrollWheel") > 0f)
                        {
                            Quaternion rotation;
                            if (controlFlag)
                            {
                                rX++;
                                rotation = Quaternion.Euler(component.transform.eulerAngles.x + (scrollDistance * (float)rX), component.transform.eulerAngles.y, component.transform.eulerAngles.z); // forward to backwards
                            }
                            else
                            {
                                if (altFlag)
                                {
                                    rZ++;
                                    rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y, component.transform.eulerAngles.z + (scrollDistance * (float)rZ)); // diagonal
                                }
                                else
                                {
                                    rY++;
                                    rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y + (scrollDistance * (float)rY), component.transform.eulerAngles.z); // left<->right
                                }
                            }
                            component.transform.rotation = rotation;
                        }
                        if (Input.GetAxis("Mouse ScrollWheel") < 0f)
                        {
                            Quaternion rotation;
                            if (controlFlag)
                            {
                                rX--;
                                rotation = Quaternion.Euler(component.transform.eulerAngles.x + (scrollDistance * (float)rX), component.transform.eulerAngles.y, component.transform.eulerAngles.z); // forward to backwards
                            }
                            else
                            {
                                if (altFlag)
                                {
                                    rZ--;
                                    rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y, component.transform.eulerAngles.z + (scrollDistance * (float)rZ)); // diagonal
                                }
                                else
                                {
                                    rY--;
                                    rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y + (scrollDistance * (float)rY), component.transform.eulerAngles.z); // left<->right
                                }
                            }

                            component.transform.rotation = rotation;
                        }


                        if (Input.GetKeyDown(KeyCode.UpArrow))
                        {
                            if (controlFlag)
                            {
                                component.transform.Translate(Vector3.up * distance * Time.deltaTime);
                            }
                            else
                            {
                                component.transform.Translate(Vector3.forward * distance * Time.deltaTime);
                            }
                        }
                        if (Input.GetKeyDown(KeyCode.DownArrow))
                        {
                            if (controlFlag)
                            {
                                component.transform.Translate(Vector3.down * distance * Time.deltaTime);
                            }
                            else
                            {
                                component.transform.Translate(Vector3.back * distance * Time.deltaTime);
                            }
                        }
                        if (Input.GetKeyDown(KeyCode.LeftArrow))
                        {
                            component.transform.Translate(Vector3.left * distance * Time.deltaTime);
                        }
                        if (Input.GetKeyDown(KeyCode.RightArrow))
                        {
                            component.transform.Translate(Vector3.right * distance * Time.deltaTime);
                        }
                    }
                }
            }