예제 #1
0
        /// <summary>
        ///  <para>
        ///   Constructs a new AntennaState given the initial values from
        ///   a pre-existing AntennaState.  This effectively makes a copy
        ///   without making the new state immutable.  This can be used to
        ///   copy states from another creature and then modified slightly.
        ///  </para>
        /// </summary>
        /// <param name="state">
        ///  AntennaState used to initialize the LeftAntenna and RightAntenna properties.
        /// </param>
        public AntennaState(AntennaState state)
        {
            leftAntenna  = AntennaPosition.Left;
            rightAntenna = AntennaPosition.Left;

            if (state != null)
            {
                if (verifyAntenna(state.LeftAntenna))
                {
                    leftAntenna = state.LeftAntenna;
                }

                if (verifyAntenna(state.RightAntenna))
                {
                    rightAntenna = state.RightAntenna;
                }
            }
        }
예제 #2
0
        /// <summary>
        ///  <para>
        ///   Constructs a new AntennaState given the initial values from
        ///   a pre-existing AntennaState.  This effectively makes a copy
        ///   without making the new state immutable.  This can be used to
        ///   copy states from another creature and then modified slightly.
        ///  </para>
        /// </summary>
        /// <param name="state">
        ///  AntennaState used to initialize the LeftAntenna and RightAntenna properties.
        /// </param>
        public AntennaState(AntennaState state)
        {
            leftAntenna = AntennaPosition.Left;
            rightAntenna = AntennaPosition.Left;

            if (state != null)
            {
                if (verifyAntenna(state.LeftAntenna))
                {
                    leftAntenna = state.LeftAntenna;
                }

                if (verifyAntenna(state.RightAntenna))
                {
                    rightAntenna = state.RightAntenna;
                }
            }
        }
예제 #3
0
 /// <summary>
 /// Helper function to update all state objects with the latest antenna
 /// information after the creature's have processed their ticks.
 /// </summary>
 private void doAntennas()
 {
     foreach (OrganismState orgState in _newWorldState.Organisms)
     {
         if (!(orgState is AnimalState)) continue;
         Animal animal = (Animal) _scheduler.GetOrganism(orgState.ID);
         AntennaState antennaState = new AntennaState(null);
         if (animal != null)
         {
             antennaState = new AntennaState((animal).Antennas);
         }
         antennaState.MakeImmutable();
         ((AnimalState) orgState).Antennas = antennaState;
     }
 }