Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6243009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:03:30+00:00 2026-05-24T12:03:30+00:00

So I have many objects with materials that each possess different properties (brick, glass,

  • 0

So I have many objects with materials that each possess different properties (brick, glass, etc.) and are each affected differently by elemental effects. A brick material for example will be affected differently by fire or acid than a cement material. A brick that’s Burning or Melting will be affected differently when another Burning/Melting effect is applied.

At this point in my game, I have an FSM but it’s very simple. If I drop a fire element on a brick, it would go to the Burning state. However if I then dropped a water element on the brick, I might want the fire to go out, take/add health and change textures (or not depending on the current combination).

The point is, I have many combinations with no commonality between them so I can’t create something uniform. Sometimes I need to change the texture and other times I don’t. Sometimes take damage while other times add health. Sometimes I need to just do nothing in a function. At this point, the only thing I can thing of is creating a global mapping such as:

FunctionMap[ObjectMaterial][CurrentObjectState][ElementBeingApplied]

(i.e.

FunctionMap[Brick][Burning][Acid]
FunctionMap[Brick][Melting][Acid]

)

The problem is, is that this is obviously a ton of functions due to the amount of combinations available with materials and effect types. Can anyone recommend a route to take or pattern to look at?

Although not entirely relevant to the discussion, this is being made in AS3 and Away3D.

Here are some of my classes for one example:

public class Brick extends AbstractBlock implements IFireable
{
    public function Brick()
    {
        super(this);
        this.material = new BitmapMaterial(_spriteManager.GetBlockMaterial(BlockUtilities.GetMaterialMap["brick_new"]));
        _type = "Brick";
        /*
        RulesManager.StateMap["Brick"]["OnFire"]["Water"] = some function;
        RulesManager.StateMap["Brick"]["OnFire"]["Fire"] = some function;
        RulesManager.StateMap["Brick"]["OnFire"]["Acid"] = some function;
        RulesManager.StateMap["Brick"]["OnFire"]["Ice"] = some function;
        RulesManager.StateMap["Brick"]["OnWater"]["Water"] = some function;
        //and so on...there are nine different materials so I'm not liking this way
        */
    }

    public override function render():void
    {
        super.render();
    }
}   


public class OnFire extends AbstractDamage
{       

    protected var _timeStart:Number = 0;

    private var _damageAccumulated:Number = 0;

    public function OnFire(block:AbstractBlock,bombType:String) 
    {       
        super(block,bombType);                                      
    }

    public override function enter():void        
    {       
        super.enter();  
    }

    public override function exit():void         
    {       
        super.exit();                                       
    }

    public override function update(time:Number):void
    {
        super.update(time);

        if(_timeStart == 0)
            _timeStart = time;

        var time_delta:Number = (time - _timeStart)/_waitTime;

        var damageToSubtract:Number = (time_delta * _damageDone);

        _damageAccumulated += damageToSubtract;

        _self.Integrity = _self.Integrity - _damageAccumulated;


    }
}

}

Thus, a fire element could be applied to a bunch of applies. One those blocks, currently frozen, is now hit and is now changing to the OnFire state. Each block has its own state machine and the states are themselves objects as you can see.

block.FSM.changeState(new OnFire(block));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:03:31+00:00Added an answer on May 24, 2026 at 12:03 pm

    So your problem is that you have 9 * 5 * 4 combinations of effects, right? Having separate functions for each of those would not be fun to manage. But, even if it’s a lot of data, you need it. I would make that data as simple as possible, then parse it. Something like:

    var materialProperties = {
      brick: {
        fire: {
          normal: {damage: 10, image: 'brick_fire.jpg'},
        }
        water: {
          fire: {damage: 0, image: 'brick_smoking.jpg'}
        }
      },
      //... a lot more of this ...
    }
    
    class Material
    {
      public var damage:int = 0;
      public var image:String = '';
    
      private var properties:Object;
      private var state:String;
    
      public function Material(properties)
      {
        this.properties = properties;
      }
    
      public function apply(effect:String):void
      {
        if(properties[effect])
        {
          if(properties[effect][state])
          {
            update(properties[effect][state]);
          }
          else if(properties[effect]['normal'])
          {
            update(properties[effect]['normal']);
          }
        }
        state = effect;
      }
    
      private function update(properties):void
      {
        damage += properties.damage;
        image = properties.image;
      }
    }
    
    var brick = new Material(materialProperties.brick);
    brick.apply('fire');
    brick.apply('water');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that has many different types of objects that each persist
I have many Topic objects and each Topic hasMany posts:Post How can I order
I have objects with many variables that I declare and explain in the comments.
I am currently working with User objects -- each of which have many Goal
Let's say I have many objects and they have many string properties. Is there
I have a project in which I have many objects with many properties whose
I have many objects in categories. like English etc French I tried to display
Let's say I'm creating an OpenGL game in C++ that will have many objects
I have a global singleton that is used by many objects in my program.
We have many objects and each objects comes with around 100-200 words description. (for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.