Esempio n. 1
0
        public override void OnInitialized()
        {
            if (VisibleTransmitters.Count == 0 || ActiveTransmitter == null)
            {
                TransmitterMaterial.SetColor("_RimColor", Color.clear);
            }

            Debug.Log("On initialized");
            worlditem.OnPlayerUse       += OnPlayerUse;
            worlditem.OnPlayerEncounter += OnPlayerEncounter;

            PowerSource                       = worlditem.GetOrAdd <LuminitePowered> ();
            PowerSource.OnLosePower          += OnLosePower;
            PowerSource.OnRestorePower       += OnRestorePower;
            PowerSource.OnPowerSourceRemoved += OnPowerSourceRemoved;
            PowerSource.PowerSourceDopplegangerProps.CopyFrom(Orb.OrbGemGenericWorldItem);
            PowerSource.FXOnRestorePower              = "ShieldEffectSubtleGold";
            PowerSource.FXOnLosePower                 = "RipEffect";
            PowerSource.FXOnPowerSourceRemoved        = "ShieldEffectSubtleGold";
            PowerSource.PowerSourceDopplegangerParent = LuminiteGemPivot;
            PowerSource.PowerAudio       = gameObject.GetComponent <AudioSource> ();
            PowerSource.CanRemoveSource  = true;
            PowerSource.CanReplaceSource = true;
            PowerSource.Refresh();

            mCameraTarget = worlditem.tr.FindChild("ConversationCameraTarget");

            DeactivateTransmitter();
        }
Esempio n. 2
0
        public override void OnInitialized()
        {
            creature = worlditem.Get <Creature> ();
            creature.OnCollectiveThoughtStart += OnCollectiveThoughtStart;
            creature.OnRevived += OnRevived;
            creature.Template.Props.CanOpenContainerOnDie = false;

            Looker looker = worlditem.Get <Looker> ();

            looker.State.ItemsOfInterest.Clear();
            looker.State.ItemsOfInterest.AddRange(ThingsOrbsFindInteresting);

            motile = worlditem.Get <Motile> ();

            OrbExplosionDamage.DamageSent      = 15f;
            OrbExplosionDamage.ForceSent       = 0.75f;
            OrbExplosionDamage.MaterialBonus   = WIMaterialType.Flesh;
            OrbExplosionDamage.MaterialPenalty = WIMaterialType.Metal;

            damageable = worlditem.Get <Damageable> ();
            damageable.State.Result = DamageableResult.Die;
            damageable.OnDie       += OnDie;

            DropItems                         = worlditem.GetOrAdd <DropItemsOnDie> ();
            DropItems.DropEffect              = "DrawAttentionToItem";
            DropItems.DropForce               = 0.05f;
            DropItems.WICategoryName          = creature.Template.Props.InventoryFillCategory;
            DropItems.RandomDropout           = 0f;
            DropItems.DropEveryItemInCategory = true;

            PowerSource = worlditem.GetOrAdd <LuminitePowered> ();

            worlditem.OnScriptAdded += OnScriptAdded;

            Meteors.Get.OnMeteorSpawned += OnMeteorSpawned;

            if (!mUpdatingBehavior)
            {
                mUpdatingBehavior = true;
                StartCoroutine(UpdateBehavior());
            }

            MeteorSearchRange = creature.Den.Radius;

            BehaviorState = OrbBehaviorState.Awakening;

            //orbs never become inactive
            worlditem.ActiveState       = WIActiveState.Active;
            worlditem.ActiveStateLocked = true;
        }
Esempio n. 3
0
 public override void OnInitialized()
 {
     PowerSource                       = worlditem.GetOrAdd <LuminitePowered> ();
     PowerSource.OnLosePower          += OnLosePower;
     PowerSource.OnRestorePower       += OnRestorePower;
     PowerSource.OnPowerSourceRemoved += OnLosePower;
     PowerSource.PowerSourceDopplegangerProps.CopyFrom(Orb.OrbGemGenericWorldItem);
     PowerSource.FXOnRestorePower              = "ShieldEffectSubtleGold";
     PowerSource.FXOnLosePower                 = "RipEffect";
     PowerSource.FXOnPowerSourceRemoved        = "ShieldEffectSubtleGold";
     PowerSource.PowerSourceDopplegangerParent = LuminiteGemPivot;
     PowerSource.PowerAudio       = Audio;
     PowerSource.CanRemoveSource  = true;
     PowerSource.CanReplaceSource = true;
     PowerSource.Refresh();
 }
Esempio n. 4
0
        protected IEnumerator UpdateBehavior()
        {
            while (!motile.HasBody || !motile.Body.HasSpawned)
            {
                yield return(null);
            }

            Transform root      = creature.Body.RootBodyPart.transform;
            Transform dropPoint = root.FindChild("OrbShellBot");

            DropItems.SpawnPoints.Add(dropPoint.localPosition);
            dropPoint = root.FindChild("OrbShellTop");
            DropItems.SpawnPoints.Add(dropPoint.localPosition);
            dropPoint = root.FindChild("OrbInnards");
            DropItems.SpawnPoints.Add(dropPoint.localPosition);

            OrbFlarePlane      = root.FindChild("OrbFlarePlane");
            LocalFlareMaterial = OrbFlarePlane.GetComponent <Renderer> ().material;

            OrbSpotlightBottom  = root.FindChild("OrbSpotlightBottom").GetComponent <Light>();
            OrbSpotlightForward = root.FindChild("OrbSpotlightForward").GetComponent <Light>();
            OrbPointLight       = root.FindChild("OrbPointLight").GetComponent <Light>();

            //we'll find the gem pivot and light pivot in the orb's root
            LuminiteGemPivot   = root.FindChild("OrbLuminiteGemPivot");
            LuminiteLightPivot = root.FindChild("OrbLuminiteLightPivot");
            Transform luminiteBits = root.FindChild("OrbTrailRenderer");

            LuminteTrail      = luminiteBits.gameObject.GetComponent <TrailRenderer> ();
            luminiteBits      = root.Find("OrbTrailParticles");
            LuminiteParticles = luminiteBits.gameObject.GetComponent <ParticleSystem> ();

            PowerSource                       = worlditem.GetOrAdd <LuminitePowered> ();
            PowerSource.OnLosePower          += OnLosePower;
            PowerSource.OnRestorePower       += OnRestorePower;
            PowerSource.OnPowerSourceRemoved += OnPowerSourceRemoved;
            PowerSource.PowerSourceDopplegangerProps.CopyFrom(OrbGemGenericWorldItem);
            PowerSource.FXOnRestorePower              = "ShieldEffectSubtleGold";
            PowerSource.FXOnLosePower                 = "RipEffect";
            PowerSource.FXOnPowerSourceRemoved        = "ShieldEffectSubtleGold";
            PowerSource.PowerSourceDopplegangerParent = LuminiteGemPivot;
            PowerSource.PowerAudio = root.FindChild("OrbPowerAudio").GetComponent <AudioSource>();
            PowerSource.Refresh();

            if (PowerSource.HasPower)
            {
                OnRestorePower();
                StartCoroutine(Burrow(true));
            }
            else
            {
                OnLosePower();
            }

            yield return(null);

            while (worlditem.Is(WILoadState.Initialized))
            {
                if (!PowerSource.HasPower)
                {
                    BehaviorState = OrbBehaviorState.Unpowered;
                }
                else if (WorldClock.IsDay)
                {
                    MeteorToGather     = null;
                    LuminiteToGather   = null;
                    ThingToInvestigate = null;
                    BehaviorState      = OrbBehaviorState.Burrowing;
                }

                IEnumerator nextTask = null;

                switch (BehaviorState)
                {
                case OrbBehaviorState.Awakening:
                    nextTask = Burrow(true);
                    break;

                case OrbBehaviorState.ConsideringOptions:
                    nextTask = ConsiderOptions();
                    break;

                case OrbBehaviorState.SeekingMeteor:
                    nextTask = SeekResources(true);
                    break;

                case OrbBehaviorState.EatingMeteor:
                    nextTask = MineResources(MeteorToGather);
                    break;

                case OrbBehaviorState.SeekingLuminite:
                    nextTask = SeekResources(false);
                    break;

                case OrbBehaviorState.EatingLuminite:
                    nextTask = MineResources(LuminiteToGather);
                    break;

                case OrbBehaviorState.SeekingItemOfInterest:
                    nextTask = SeekItemOfInterest();
                    break;

                case OrbBehaviorState.Unpowered:
                    MeteorToGather     = null;
                    LuminiteToGather   = null;
                    ThingToInvestigate = null;
                    if (worlditem.Is <Hostile> (out hostile))
                    {
                        hostile.Finish();
                    }
                    nextTask = WaitForPower();
                    break;

                case OrbBehaviorState.Burrowing:
                    MeteorToGather     = null;
                    LuminiteToGather   = null;
                    ThingToInvestigate = null;
                    if (worlditem.Is <Hostile> (out hostile))
                    {
                        hostile.Finish();
                    }
                    nextTask = Burrow(false);
                    break;

                case OrbBehaviorState.Despawning:
                    Debug.Log("Despawning");
                    //never save orb states
                    if (thingsInvestigatedTonight != null)
                    {
                        thingsInvestigatedTonight.Clear();
                        thingsInvestigatedTonight = null;
                    }
                    break;
                }

                if (nextTask != null)
                {
                    while (nextTask.MoveNext())
                    {
                        yield return(nextTask.Current);
                    }
                }

                double waitUntil = WorldClock.AdjustedRealTime + 0.5f;
                while (WorldClock.AdjustedRealTime < waitUntil)
                {
                    yield return(null);
                }
            }

            mUpdatingBehavior = false;
        }