예제 #1
0
        public override void OnInitialized()
        {
            CheckTemplate();

            worlditem.OnActive          += OnActive;
            worlditem.OnVisible         += OnVisible;
            worlditem.OnInactive        += OnInactive;
            worlditem.OnPlayerEncounter += OnPlayerEncounter;
            worlditem.OnAddedToGroup    += OnAddedToGroup;

            photosensitive = worlditem.GetOrAdd <Photosensitive> ();
            photosensitive.OnExposureDecrease += RefreshEyes;
            photosensitive.OnExposureDecrease += RefreshEyes;

            Motile motile = null;

            if (worlditem.Is <Motile> (out motile))
            {
                motile.SetBody(Body);
                //always set the motile props even if we've saved the state
                motile.State.MotileProps = Template.MotileTemplate.MotileProps;
            }
            Looker looker = null;

            if (worlditem.Is <Looker> (out looker))
            {
                looker.OnSeeItemOfInterest += OnSeeItemOfInterest;
            }
            Listener listener = null;

            if (worlditem.Is <Listener> (out listener))
            {
                listener.OnHearItemOfInterest += OnHearItemOfInterest;
            }
            damageable = worlditem.Get <Damageable> ();
            damageable.OnTakeDamage         += OnTakeDamage;
            damageable.OnTakeCriticalDamage += OnTakeCriticalDamage;
            damageable.OnTakeOverkillDamage += OnTakeOverkillDamage;
            damageable.OnDie += OnDie;

            Container container = worlditem.Get <Container> ();

            container.CanOpen      = false;
            container.CanUseToOpen = false;

            OnDaytimeStart   += RefreshBehavior;
            OnNightTimeStart += RefreshBehavior;
            OnHourStart      += RefreshBehavior;

            //WanderAction ();
        }